I'm somehow new to Django and it's my first time to implementing a signUp form with sms verification.
I get the user mobile number and generate a random number and send to him; I want the generated code to be expired after 30 minutes and after that I don't need them, so it seems that it is not a good idea to save them in DB and after the expiration time, delete them.
I wonder if anybody can help me with the the question that "what is the best way to implement this?"
Thank you so much in advance
Go to Settings > Passwords, then select your account for the website or app. Tap Set Up Verification Code, then tap Enter Setup Key.
From your iPhone, iPad, or iPod touchGo to Settings > [your name]. Tap Password & Security > Get Verification Code.
You need to install the Google Authenticator app on your smart phone or tablet devices. It generates a six-digit number, which changes every 30 seconds. With the app, you don't have to wait a few seconds to receive a text message.
save them in Redis. Redis keys can have a TTL(Time-To-Live), keys with TTL are deleted automatically after the time period.
import redis
r = redis.StrictRedis()
# create pin
r.set("<phone-number>", <sms-pin>)
r.expire("<phone-number>", 1800) # 1800 seconds = 1/2 hour
# get pin
if r.exists("<phone-number>"):
pin=r.get("<phone-number>")
... validate pin
else:
... invalid pin
More docs at http://agiliq.com/blog/2015/03/getting-started-with-redis-py/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With