Registers a new user in the DB.
Parameter | Type |
---|---|
firstName | string |
lastName | string |
username | string |
string | |
password | string |
{
"firstName": "John",
"lastName": "Doe",
"username": "JohnUndefined",
"email": "[email protected]",
"password": "password"
}
- Success -
Code: 200
{
{
"firstName": "John",
"lastName": "Doe",
"username": "JohnUndefined",
"email": "[email protected]",
"password": "[HashedPassword]",
"type": "user",
"ratings": [],
"_id": "[MongooseId]",
"createdOn": "2022-03-03T21:01:37.531Z",
"__v": 0
}
}
- Failure -
Code: 400
{
"errors": [
{
"value": "test132",
"msg": "Username already in use.",
"param": "username",
"location": "body"
},
{
"value": "[email protected]",
"msg": "E-mail already in use.",
"param": "email",
"location": "body"
}
]
}
Creates a session with user for 24 hours.
Parameter | Type |
---|---|
string | |
password | string |
{
"email": "[email protected]",
"password": "password"
}
- Success -
Code: 200
{
"message": "Logged in successfully."
}
- Failure -
Code: 404
{
"error": "User with this email does not exist."
}
Removes a session created with user. To access some data you need to log in again.
- Success -
Code: 200
{
"message": "Logged out successfully."
}
Allows user to change email.
Parameter | Type |
---|---|
string | |
password | string |
{
"email": "[email protected]",
"password": "password"
}
- Success -
Code: 200
{
message: 'E-mail successfully updated.'
}
- Failure -
Code: 400
{
message: 'Email has been taken.'
}
Allows user to change password.
Parameter | Type |
---|---|
password | string |
newPassword | string |
passwordConfirmation | string |
{
"password": "password",
"newPassword": "testPass"
"passwordConfirmation": "testPass"
}
- Success -
Code: 200
{
message: 'E-mail successfully updated.'
}
- Failure -
Code: 400
{
"errors":
[
{
"value": "password",
"msg": "Password confirmation does not match password.",
"param": "passwordConfirmation",
"location": "body"
}
]
}