Question

As a user register in my website, a registration link will send him. What i want is to expire this link after 48 hours. Is there any way to do that? Thank you so much. here is my codes: In activate page:

 string userID = Request.QueryString["userID"];
   Guid gd = new Guid(userID);
   Membership.UpdateUser(user);

In activate page:

 MembershipUser user = Membership.CreateUser(TextBox_email.Text, TextBox_Pass.Text, TextBox_email.Text);

                   Roles.AddUserToRole(TextBox_email.Text, "Author");
                   user.IsApproved = false;
                   Membership.UpdateUser(user);

                   //  StringBuilder bodyMsg = new StringBuilder();

                   Guid userID = (Guid)user.ProviderUserKey;
Was it helpful?

Solution

I guess this is all about special querystring/route parameters in your activation link

You can, for example :

  • store a link identifier and the date it has been issued in a datastore/database. Then check that a user link is no more than 48h old when a user accesses your site with it.
  • store a timestamp in the link itself (no need of a db), as well as a hashcode of the timestamp concatenated to a secret key of yours. When a user comes with a link, verify that the hashcode and the timestamp match, then verify that the timestamp is no more than 48h old
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top