mycookbook / web-client

cookbookshq frontend
https://web.cookbookshq.com
Other
1 stars 1 forks source link

Implement OTP #169

Open fokosun opened 1 year ago

fokosun commented 1 year ago

An OTP is a mechanism that will serve as an authentication mechanism for users without a session.

Task: In the report recipe page, consume the backend to generate an OTP for a user. The user is expected to get the code in their email or phone. The frontend should confirm this code by communicating with the backend. The user cannot proceed if the server does not respond with a 200.

Modify the form to accept email or phone number

fokosun commented 1 year ago

@captainPrime I'm working on the backend piece of this. I'll let you know when you can test and re open your draft pr https://github.com/mycookbook/web-client/pull/178

fokosun commented 1 year ago

@captainPrime the backend piece is deployed to staging now. You can consume the endpoints to test locally then re open this PR for review

Generate OTP

POST /api/v1/otp/generate

body {
    'identifier': 'email or phone'
}

Validate OTP

POST /api/v1/otp/validate

body {
    'identifier': 'email or phone used to obtain token',
    'token': {token}
}

Responses

On Success
{
  "status": true,
  "message": "OTP is valid"
}

Does not exist
{
  "status": false,
  "message": "OTP does not exist"
}

Not Valid*
{
  "status": false,
  "message": "OTP is not valid"
}

Expired
{
  "status": false,
  "message": "OTP Expired"
}