Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
How can I add time limitations in asp.net identity 2 when I send an SMS verification code?
Thanks

What I have tried:

I tried it for email but I could not find it for sms.
Posted
Updated 9-Oct-20 20:17pm

1 solution

You add your expiry in exactly the same way as for an email: the page or code you send expires at a specific time you store with the code (or page link) when you send it.

You create a code, you store it in a DB against the user number, and you add an expiry time to that store. When the user enters a code, you retrieve the information from the table using the user number, check the expiry and only check the actual code if it hasn't expired yet.

Think of it like a real world homework assignment: you (the teacher) set the class an assignment on Friday and say they must hand it in on Monday. When a student hands in his homework, you check the day and only accept the homework if it is Friday, Saturday, Sunday, or Monday. If they hand in the homework on Tuesday, Wednesday, or Thursday you reject it and give a fail without even looking at it!

The homework assignment is the code or page you send the user by SMS or email, "Monday" is the expiry date. The only difference is that each student gets different homework!

Have a think about it, and stop assuming you will find code that solves your exact problem online: you won't. You will always need to think about, understand, and alter such code before you can use it!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900