Generate a new Guid, and store it in the database.
In the email your link should contain the same guid in the query string.
Now in your web page you should check if the guid matches then you log the user automatically to his account.
Explanation:
You can create a new table that stores the guid and the user id
Before you send the email to a user you store that guid with user id in the table. The table structure is given below:
User Id
Guid
1
0f8fad5b-d9cb-469f-a165-70867728950e
Now when you end the email give a login to your account link that contains the same guid in query string.
<a href="http://www.yourwebsite.com/login/?guid=0f8fad5b-d9cb-469f-a165-70867728950e">Login to your account</a>
So when the user clicks the link he reaches the website's login page. In that login page you extract the guid value from query string. Then you match the guid with the guid column of the table. So you get the User Id of the person.
Now you know which user has clicked the link and you do the automatic login.
Some website also adds the expiry time of the guid. For this they add a new
ExpiryTime column on the table. And this helps them to prevent users to use the link for login after the exprity time has reached.
I hope I am clear in my explanation.
Thanks You, YOGI
Helping you always. Don't forget to click "Mark as Answer" on the post that helped you.
♠ ASP.NET Core Tutorials → Start from the Beginning and become an Expert in 30 days time ♠
None
0 Points
1 Post
How to redirect user to dashboard after clicking on email notification?
Dec 11, 2018 05:23 AM|Kamayani|LINK
Hello,
After user has registered / email notification after clicking link, how to redirect user to his account without asking to login.
Your help is very much appreciated.
Participant
1253 Points
943 Posts
Re: How to redirect user to dashboard after clicking on email notification?
Dec 11, 2018 10:29 AM|yogyogi|LINK
You can do these things:
Explanation:
So when the user clicks the link he reaches the website's login page. In that login page you extract the guid value from query string. Then you match the guid with the guid column of the table. So you get the User Id of the person.
Now you know which user has clicked the link and you do the automatic login.
Some website also adds the expiry time of the guid. For this they add a new ExpiryTime column on the table. And this helps them to prevent users to use the link for login after the exprity time has reached.
I hope I am clear in my explanation.
Thanks You,
YOGI
♠ ASP.NET Core Tutorials → Start from the Beginning and become an Expert in 30 days time ♠