Generate temporary URL to reset password

前端 未结 9 673
隐瞒了意图╮
隐瞒了意图╮ 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:33

    I used a Hashing Class to create unique automatic logins made up of the current date/time and the users email address:

    string strNow = DateTime.Now.ToString();
    string strHash = strNow + strEmail;
    strHash = Hash.GetHash(strHash, Hash.HashType.SHA1);
    

    get the Hash Class from: http://www.developerfusion.com/code/4601/create-hashes-md5-sha1-sha256-sha384-sha512/

    Then just take it from the URL using:

    if (Request.QueryString["hash"] != null)
    {
                    //extract Hash from the URL
                    string strHash = Request.QueryString["hash"];
    }
    

提交回复
热议问题