Save an OTP Code from a custom action to another collection

Hi,

I made a custom action using ClickSend to send SMS Code (it works well, I receive the code)
In the custom action I’ve put 2 input, one for the phone number, the other one for the code.
I select the phone number from the component, then RAND(111111,999999) in the phone number property, but how do I also save that code in the, for example PendingUser, so I can put an action on the OTP Input to create the user only if OTP Input = Current PendingUser Code.

Everything is already prepared, I just want to know how to save the code in the Current PendingUser also

Thank you for your help

Hello, how are you? If it’s a verification OTP, for example, the user registers and you send them an OTP, you can add an OTP property to the user database. Then, when you press send, you perform an action that is “Update Logged In User > OTP” and save the RAND you created.

Verify User: On the screen, add an input and a button. Add a condition to the button that executes the action: go to home if the input is equal to the logged-in user > OTP. Otherwise, it says the OTP is incorrect.

In the “Continue” button, you must add an action to update the logged-in user to verified > true.

Option 2:
If the user doesn’t exist, you can have the OTP saved in a hidden input on the screen.

You add an input that is to write the OTP… and the same process as the other… that the button executes the action if the OTP input is equal to the hidden input… the action you want to go to signup, etc. etc. etc.

That’s what I don’t know how to, save the OTP created by the custom action into the user collection, I can’t select the code with the magic text, maybe there’s something I’m missing, I’m still learning

The question is… is the OTP sent when the user created the account?

Okay, so I had mixed things up a bit. I created the OTP with the custom action and then created the user, but it was the other way around: create the user, generate the code, and then place the code in the custom action with the magic text.

Now, even when I use sign up option, if the code is correct, it tells me that an account already exists (on purpose), but it still creates the user in the USERS database.

The key issue seems to be that a user record is being created even when the OTP verification fails. go with reversing the flow

  • User’s email or phone number without creating a user record yet.

  • Use a custom action to generate an OTP & send it to the user via email or SMS. store this OTP in a temporary collection + user’s contact information.

  • Prompt the user to enter the OTP. Upon submission, validate the entered OTP against the one stored in the temporary collection.

  • Only if the OTP matches should proceed to create the user in the main Users collection.

  • After successful verification and user creation, remove the temporary data from the OTP collection

Don’t worry, everything can be solved with a little ingenuity.

You can add an action on the home page or splash screen to take the logged-in user to the verification page if they are not verified.

On that page, you add an input and three buttons:

Input: to enter the OTP

Button 1: to verify if the input is equal to OTP > user
Action: if it is equal, update the logged-in user as verified > true

Button 2: request a new OTP.
Action: update logged-in user OTP > rand (100000, 999999) and send the new OTP to the user.

Button 3: Delete my account.

Hi,

I managed to set up a whole sign up and login system that uses an OTP (by sms in my case), here’s what I did:

  • A button on the Welcome Screen leading to a page with a phone number input,

  • A phone number input, including the country code for sms sending

  • A button, which I transformed into a list of USERS > Phone Number is equal phone number input, adding a visibility condition. It takes you to a screen with an OTP input for login, carrying with it Current User data.

  • A button with visibility condition USERS count > filters > Phone Number is equal Phone number input & Verified is true > 0 which takes you to a screen identical to the login screen, but for registration.

  • The two buttons send an SMS using the code generated RAND(111111,999999) in the Current User (login) or Logged-In User (Registration).

  • I’ve added a limit to the number of connection attempts, so the OTP confirmation button only appears if Attempt made is less than 3. A warning message appears.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.