-
Notifications
You must be signed in to change notification settings - Fork 6
resetPasswordApi
The Reset Password API offers two distinct methods to facilitate password resets: GET
and PUT
. The choice of method depends on the user's authentication status and the need for resetting the password.
When a user is logged in or presents a valid JWT token and intends to change their password, the API expects a PUT request. This method requires the user to input their current password along with the new password.
For scenarios where the user is not logged in or does not recall their current password, it's recommended to perform a client-side logout before initiating a GET request. This method expects the user's email, triggering the sending of a token that comprises of their username and OTP (One-Time Password) to the user's email address. Verification of this token enables the user to set a new password.
-
URL:
https://industrialiot.onrender.com/api/resetpass
-
Method:
PUT
GET
-
Headers:
-
Authorization:
Bearer <ACCESS_TOKEN>
- (forPUT
method only) -
Content-Type:
application/json
-
Authorization:
-
Body Parameters:
-
For
PUT
method:Parameter Type Description oldpass
String User's current password (required) newpass
String User's new password (required) Note: Do not forget to do a client side verification for newpass to confirm that user is aware of characters of his password.
-
For
GET
method:Parameter Type Description email
String User's email address (required)
-
-
For
PUT
method:-
Success Response:
- Status Code: 200 OK
-
Response Body:
{ "success": "password updated successfully" }
- Description: Indicates a successful password update.
-
Error Responses:
-
Status Code: 400 Bad Request
-
Response Body:
{ "error": "Incorrect old password, logout to reset password or try again" }
- Description: Indicates an incorrect current password provided.
-
Response Body:
-
Status Code: 500 Internal Server Error
-
Response Body:
{ "error": "failed to update password", "details": "<Error Details>" }
- Description: Indicates a failure to update the password due to an internal server error.
-
Response Body:
-
Status Code: 400 Bad Request
-
-
For
GET
method:-
Success Response:
- Status Code: 200 OK
-
Response Body:
{ "success": "token sent to email" }
- Description: Indicates successful token generation and email sent for OTP verification.
-
Error Responses:
-
Status Code: 400 Bad Request
-
Response Body:
{ "error": "incorrect email" }
- Description: Indicates an incorrect email provided or the email not being registered..
-
Response Body:
-
Status Code: 500 Internal Server Error
-
Response Body:
{ "error": "failed to store token", "details": "<Error Details>" }
- Description: Indicates a failure to send the OTP email due to an internal server error.
-
Response Body:
-
-
-
For
PUT
method:-
Request Method:
PUT
-
Endpoint URL:
https://industrialiot.onrender.com/api/resetpass
-
Header:
Authorization: Bearer <JWT> Content-Type: application/json
-
Request Body:
{ "oldpass": "<CURRENT_PASSWORD>", "newpass": "<NEW_PASSWORD>" }
Note: Replace
<CURRENT_PASSWORD>
with the user's current password and<NEW_PASSWORD>
with the desired new password.
-
-
For
GET
method:-
Request Method:
GET
-
Endpoint URL:
https://industrialiot.onrender.com/api/resetpass
-
Header:
Content-Type: application/json
-
Request Body:
{ "email": "<USER_EMAIL>" }
-
For utilizing the OTP sent for verification purpose in other to complete password reset, click here. For more details on this, check here
Please ensure to perform a client-side logout before initiating the GET request in cases where the user is not logged in or does not remember their current password.