Password Reset Post
/api/v2/user/password/reset
Post
users
Purpose
To allow a registered user to reset his / her password.
URL Parameters [input]
{
username: string,
token: string,
password: string
}
Returns if valid [output]
{
message: string,
error: 0
}
What the API does
- Checks if there is a record in the
users
collection with theusername
supplied [404]. - Checks if the value of the
reset
field of the fetched record has a value oftrue
[403]. - Checks if the
token
supplied is valid and corresponds to the one saved in the fetched record [401]. - Checks if the
password
supplied contains at least 1 lowercase alphabet, 1 uppercase alphabet, 1 numerical character and that it is at least 8 characters long [400]. - Sends a mail to the email address corresponding to the value of the
prev_email
field of the found record to inform the user that his/her password has just been reset. - Updates and saves the
users
collection by setting thereset
field tofalse
, thetoken
field to an empty string and thepassword
field to a hashed version of the one supplied for the record corresponding to the value of theusername
field provided.