I am using email otp verification, where I send an email along with an server-side generated(server action in the core services module) otp to a particular email address.Now when the user enters the otp, how do I compare the sent otp and the user entered otp on server side?Is there a way to temporarily store the otp when I send the mail(like redis, and then on expiry/entering the otp gets deleted), which i can compare the entered otp with? I also want the otp to expire in two mins.
Or is there some other way to compare the otps?
Dear Amol,Good DayYou can create like below as per your requirements:1) From user Validation Screen call one Server Action 'ValidateOTP' with user OTP & email/username as input parameters2) Server Action -> ValidateOTP which will have input OTP+email/username parameter from User screen.3) In ServerAction ValidateOTP, check currentdatetime in action with your your saved datetime. Hope you are saving datetime somewhere in database along with OTP & email/username in database. 4) If OTP matches and its within 2 minutes, return IsSuccess = true from server action. Else false. Rest of the logic will be based on your validation success true or false. Hope this is what you were looking for. Regards,Palak Patel
Thanks for your prompt answer. But how do I delete unverified OTPs from the database?That is, if someone asks for an otp, but doesnt verify it, i want that to be deleted automatically after 2 mins. Can this be done?
Hello Amol, sorry for the late reply, but yes it's actually possible by using Outsystems timers, you can set up one which will delete each 24 hours expired OTPs from your database,
i hope by this time, you already found a solution to your issue.