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
users
collection with ausername
oremail
corresponding to the value of theauth_data
supplied [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
active
field from the retrieved collection record [403]. - Sets the
deactivated
andreset
bool
tofalse
and saves the record. - Generates a
jwt
using an algorithm for theheader
, a secret key for thekey
and uses theuser
’suid
as theiss
part and a value of a defined number of minutes for theexp
part of thepayload
.