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
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
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.
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.