title: SMS verification NodeJS
body: <p>I'am building a blog with <code>NodeJS</code>, <code>Express</code> and <code>MongoDB</code>, its a simple REST API where I can post blogs, signup, login, etc.</p>
  
  <p>I want to build a SMS verification system using twilio, which is pretty easy, generate some CODE, send it to user phone number with twilio and when user post to <code>/verify</code>, I'm checking the code and update the user.</p>
  
  <p>My problem is that I'm not sure where to store the generated code.
  From what I searched I can do the following ways:</p>
  
  <ol>
  <li><p>Store the code in User model (<code>user.verificationCode = GENERATED_CODE</code>)</p></li>
  <li><p>Store the code in user session</p></li>
  <li><p>Make a new model called code and save it <code>{ user: ObjectId(USER_ID), code: GENERATED_CODE }</code>  </p></li>
  </ol>
  
  <p>But I'm not sure if this is best practice, can someone explain whats the best way do to this?</p>