You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement a feature to send an OTP to the user for the endpoint api/v1/auth/request/token. Before sending a new OTP, the system should check if an existing OTP for the user already exists. If an existing OTP is found, it should be deleted before a new OTP is generated and sent.
Acceptance Criteria
The endpoint must return a 422 error for missing or invalid input with an appropriate error message.
A 401 status code should be returned for invalid credentials with an appropriate error message.
A successful request should return a 200 response with a success message.
OTP should be transmitted securely to the user via email or SMS.
Once validation checks are passed, an OTP is generated for the user and sent as part of the response payload.
Expected Outcome
The user should receive the OTP successfully or receive an error message if unsuccessful.
Users are informed of OTP request activity.
Requirements
Corresponding database fields for:
Email Address
OTP Token
OTP Expiry Time
Send OTP [POST] /api/v1/auth/request/token
Request
POST /api/v1/auth/request/tokenContent-Type: application/json
{
"email": "[email protected]"
}
{
"message": "User not found.",
"error": "No user exists with the provided email.",
"status_code": 401
}
Implementation Steps
New Method in AuthService:
Create a new method requestOtp in authservice.ts that handles the logic for checking existing OTPs, deleting them if found, generating a new OTP, and sending it to the user.
Modify OTP Service:
Update the OTP service to include a method for checking existing OTPs and deleting them.
Update Routes:
Add a new route in the authentication routes file to handle requests to api/v1/auth/request/token.
Unit Tests:
Write unit tests for the new method to ensure it behaves as expected, including scenarios where an existing OTP is found and deleted, and where no existing OTP is found.
Check List
Endpoint api/v1/auth/request/token created
Logic to check for existing OTP and delete if found
Logic to generate and send new OTP
Appropriate success and error responses
Unit tests for new functionality
The text was updated successfully, but these errors were encountered:
Description
Implement a feature to send an OTP to the user for the endpoint
api/v1/auth/request/token
. Before sending a new OTP, the system should check if an existing OTP for the user already exists. If an existing OTP is found, it should be deleted before a new OTP is generated and sent.Acceptance Criteria
Expected Outcome
Requirements
Corresponding database fields for:
Send OTP [POST] /api/v1/auth/request/token
Request
Successful Response
Error Response
Missing or Invalid Input
Invalid Credentials
Implementation Steps
New Method in AuthService:
requestOtp
inauthservice.ts
that handles the logic for checking existing OTPs, deleting them if found, generating a new OTP, and sending it to the user.Modify OTP Service:
Update Routes:
api/v1/auth/request/token
.Unit Tests:
Check List
api/v1/auth/request/token
createdThe text was updated successfully, but these errors were encountered: