Back

Functions

  • 0
  • Flutter
Joshima
1 Jun, 2023, 15:04

i have made an api_function where i am sending otp to the user and now i want to check if the entered otp and the generated otp is correct so how do i get the otp generated from the backend appwrite . here's my otp sending function - ``` @override FutureEither<Execution> otp({required String data}) async { try{ final functionss = await _function.createExecution( functionId: 'UserAuth', data: data, ); verifyOTP(enteredOTP: functionss.response); print(functionss.response);

TypeScript
        return right(functionss);
    } catch (e, stackTrace) {
      return left(
        Failure(e.toString(), stackTrace)
      );
    }

  }```
TL;DR
The user is asking for help verifying an OTP (one-time password) in Appwrite. They are unsure how to retrieve the generated OTP from the backend. The solution is to either take the `functionss.response` outside of the `otp` function or create another `verifyotp` function.
Drake
1 Jun, 2023, 21:27

How did you generate the OTP?

Joshima
2 Jun, 2023, 04:33

from backend - python

Drake
2 Jun, 2023, 04:35

Okay.... Sorry I'm a little lost

Drake
2 Jun, 2023, 04:36

What exactly are you stuck with?

Joshima
2 Jun, 2023, 04:38

so here in the otp function , (functionss.response) is the generated otp and now i want to check if the otp the user entered and this generated otp is equal or not so to do that either i need to take this functionss.response out of this api fucntion(otp) which i dont know how to or i can make another verifyotp api function but how to retrieve (functionss.response) out of otp function

Drake
2 Jun, 2023, 04:41

In general, it doesn't make sense to return the otp to the channel the client sent the request from 🧐

Joshima
2 Jun, 2023, 04:42

so how could i verify

Drake
2 Jun, 2023, 04:44

Perhaps you should do some research on how the otp flow should work first before trying to do it in Appwrite

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more