verifyemailApi - n1lby73/industrial-IOT GitHub Wiki
The Email Verification API allows users to verify their email addresses using a one-time password (OTP) generated and sent to their registered email. Upon successful verification, the user's email will be marked as verified.
-
URL:
https://industrialiot.onrender.com/api/verifyemail -
Allowed Methods:
HTTP Method Function POSTFor completing email verification PUTFor changing email where otp is sent to - for cases of typo during registration GETRequesting new OTP - cases of expired OTP
-
Headers:
-
Content-Type:
application/json
-
Content-Type:
-
Body Parameters:
-
For
POSTmethod:Parameter Type Description otpString The one-time password received via email (required). emailString User's email where otp was sent (required) -
For
PUTmethod:Parameter Type Description emailString User's initial email address used in the registering phase (required) newEmailString New email to send OTP code (required) -
For
GETmethod:Parameter Type Description emailString User's email address (required)
-
-
For
POSTmethod:-
Success Response:
-
Status Code: 200 OK
-
Response Body:
{ "success": "email verified successfully" }
-
-
Error Responses:
-
Status Code: 400 Bad Request
-
Response Body:
{ "error": "email does not exist" } -
Reason: The email sent to verify has not been registered or does not exist in the database
-
-
Status Code: 409 Conflict
-
Response Body:
{ "alert":"email verification already completed" } -
Reason: The email sent to verify has already been verified
-
-
Status Code: 400 Bad Request
-
Response Body:
{ "error": "invalid otp entered" } -
Reason: User input a wrong OTP that was not stored in the database
-
-
Status Code: 400 Bad Request
-
Response Body:
{ "error": "expired otp, request for a new one" } -
Reason: OTP timeout has elapsed
-
-
Status Code: 500 Internal Server Error
-
Response Body:
{ "error": "failed to update db", "details": "<error details>" } -
Reason: Indicates an error to populate database with new data within the server
-
-
Status Code: 500 Internal Server Error
-
Response Body:
{ "error": "verification unsuccessfull", "details": "<error details>" } -
Reason: Indicates an error to complete email verification
-
-
-
For
PUTmethod:-
Success Response:
- Status Code: 200 OK
-
Response Body:
{ "success": "email update completed and otp sent to new email", "email": "<updated Email>" }- Description: Indicates a successful email change.
-
Error Responses:
-
Status Code: 409 conflict
-
Response Body:
{ "alert": "email already exist, login instead" } - Description: Indicates that email user intends to switch to already exist.
-
Response Body:
-
Status Code: 400 Bad Request
-
Response Body:
{ "error": "invalid email format" } - Description: Indicates the user email is not a valid format
-
Response Body:
-
Status Code: 400 Bad Request
-
Response Body:
{ "error":"invalid old email" } - Description: Indicates the old email is not a valid one
-
Response Body:
-
Status Code: 500 Internal Server Error
-
Response Body:
{ "error": "update unsuccessfull", "details": "<Error Details>" } - Description: Indicates a failure to update the email due to an internal server error.
-
Response Body:
-
-
-
For
GETmethod:-
Success Response:
- Status Code: 200 OK
-
Response Body:
{ "success": "otp sent to mail" }- Description: Indicates successful OTP generation and email sent for OTP verification.
-
Error Responses:
-
Status Code: 409 conflict
-
Response Body:
{ "alert": "email already exist, login instead" } - Description: Indicates that email user is requestng OTP for has already been verified.
-
Response Body:
-
Status Code: 400 Bad Request
-
Response Body:
{ "error": "invalid email format" } - Description: Indicates the user email is not a valid format
-
Response Body:
-
Status Code: 500 Internal Server Error
-
Response Body:
{ "error": "could not update db", "details": "<Error Details>" } - Description: Indicates a failure to update the database with the new OTP
-
Response Body:
-
Status Code: 500 Internal Server Error
-
Response Body:
{ "error": "OTP generation failed" } - Description: Indicates a failure to generate the OTP due to an internal server error.
-
Response Body:
-
-
-
For
POSTmethod:-
Request Method:
POST -
Endpoint URL:
https://industrialiot.onrender.com/api/verifyemail -
Header:
Content-Type: application/json -
Request Body:
{ "otp": "<OTP sent to mail>", "email": "<Email to be verified>" }
-
-
For
PUTmethod:-
Request Method:
PUT -
Endpoint URL:
https://industrialiot.onrender.com/api/verifyemail -
Header:
Content-Type: application/json -
Request Body:
{ "email": "<Email used during registration>", "newEmail": "<Email to change to>" }
-
-
For
GETmethod:-
Request Method:
GET -
Endpoint URL:
https://industrialiot.onrender.com/api/verifyemail -
Header:
Content-Type: application/json -
Request Body:
{ "email": "<USER_EMAIL>" }
-