Login
/api/v2/user/login
Post
users
Purpose
To allow a registered user to login on the platform.
Body Content [input]
{
auth_data: string,
password: string
}
Returns if valid [output]
{
uid: string,
name: string,
username: string,
email: string,
prev_email: string,
jwt: string,
error: 0
}
What the API does
- Checks if there is a record in the
userscollection with ausernameoremailcorresponding to the value of theauth_datasupplied [404]. - Compares the saved hashed password with a hashed version of the one supplied to check if the password is correct [401].
- Checks if the user’s account is activated using the stored
activefield from the retrieved collection record [403]. - Sets the
deactivatedandresetbooltofalseand saves the record. - Generates a
jwtusing an algorithm for theheader, a secret key for thekeyand uses theuser’suidas theisspart and a value of a defined number of minutes for theexppart of thepayload.