node.js - SMS verification NodeJS -


i'am building blog nodejs, express , mongodb, simple rest api can post blogs, signup, login, etc.

i want build sms verification system using twilio, pretty easy, generate code, send user phone number twilio , when user post /verify, i'm checking code , update user.

my problem i'm not sure store generated code. searched can following ways:

  1. store code in user model (user.verificationcode = generated_code)

  2. store code in user session

  3. make new model called code , save { user: objectid(user_id), code: generated_code }

but i'm not sure if best practice, can explain whats best way this?

option 3 not make sense. , go option 1 or option 2 depends on how long can wait user enter code. , life of session. whether session going expire on browser close or not?

generally suggest go option 2. assuming user going feed code before session expires. typical case.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -