One time password to email

Options
Maybe you can help me. How can i develop the feature - One Time Password. generate, send it on email and user need to enter 4 digits to access

A think a can do it. with Magic Link via SendGrid, but it generates a long token, and i need just 4 numbers

Comments

  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
    Yes - I've seen people customize the magic link template to do this. Instead of generating a magic token and magic link, they've used the Generate Random Number function to create a random 4 digit number. 

    This can be stored in the database as an object similar to the Magic Link object, but it would have the 4 digit code, an expiration, and a boolean for if used. Every time a code is generated overwrite the previous object with the new data.

    Send the 4 digit code to the user, you'll need to have them input the 4 digit code and check it against the code, expiration time, and boolean in the database. If it all checks out (against Preconditions) then you can create the authentication token and mark the boolean as used.