Generate temporary URL to reset password

前端 未结 9 584
隐瞒了意图╮
隐瞒了意图╮ 2021-01-30 02:08

I am looking to implement a Forgot Password feature on my website. I like the option where an email containing a temporary one-time use URL that expires after some time is sent

9条回答
  •  野的像风
    2021-01-30 02:14

    Here, the System.Guid class in your friend, as it will generate a unique (well, unique enough) 128-bit number:

    • Generate a new Guid ( System.Guid.NewGuid() )
    • Store that Guid somewhere (Application object maybe?)
    • Send a custom URL in an email with that Guid
    • When the user hits the site, make them enter the password you sent in the email
    • If the passwords match, go ahead and force them to enter a new password

提交回复
热议问题