-
Notifications
You must be signed in to change notification settings - Fork 0
Authorization
Vadim Sokoltsov edited this page Apr 6, 2017
·
3 revisions
Sign in user and create new authorizaiton object (or update previous)
-
email- type:string- user's email -requered -
password- type:string- user's password -requered -
authorization- type:json- object with information about user's client -required
authorization object should include fields:
-
platform- information about client's OS -
platform_version- version of client's OS -
app_name- name of the client (browser version, mobile app name, etc.) -
app_version- version of the client (browser version, mobile app name, etc.) -
provider- default:UProgress- name of the application through which authorization has been completed
- email -
can't be blank,is invalid - password -
can't be blank,is too short (minimum is 6 characters) - authorization -
can't be blank
-
token- encrypted authorization token
{
"user": {
"email": "ololosh@mail.ru",
"password": "Password123",
"authorization": {
"platform": "macOS",
"platform_version": "10.11",
"app": "Google Chrome",
"app_version": "56.14.3",
"provider": "UProgress"
}
}
}{
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MTA0OX0.B0X5T35HnHJ_2AxoKp6CeiTTq2n_lcoHc5X7hNGdFo0"
}{
"errors": {
"email": [
"can't be blank",
"is invalid"
]
}
}Receive current user information
None
Available messages:
- User not found
- Authorization token invalid
- Authorization token expired
{
"current_user": {
"id": <user id>,
"email": <user email>,
"nick": <user nick>,
"first_name": null,
"last_name": null,
"description": null,
"location": null,
"attachment": null
}
}{
"user": null
}Send restore password message and receives token for password reset
-
email- type:string- user's email -REQUIRED
-
token- type:string- token for reset password
- email -
can't be blank,There is no such user
POST /api/v1/sessions/restore_password HTTP/1.1
Host: dockerhost:3000
Content-Type: application/json
uprogresstoken: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MX0.DeefNqb69orzcJu8RIq9ClD4ZPTOF1R6yC1ABiBB6BY
Cache-Control: no-cache
{
"user": {
"email": "vforvad@gmail.com"
}
}{
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MjF9.swhph2cSQ74nkLQ75n3WSC5qgmggR9-_uHyyALbaDlQ",
"message": "Mail was succesfully sended"
}{
"errors": {
"email": [
"can't be blank"
]
}
}Reset user's password
-
password- type:string- password value -
password_confirmation- type:string- password confirmation value -
token- type:string- reset password token value
-
message- type:string- success reset password message
PUT /api/v1/sessions/reset_password HTTP/1.1
Host: dockerhost:3000
Content-Type: application/json
Cache-Control: no-cache
{
"user": {
"password": "Altair_69",
"password_confirmation": "Altair_69",
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MjF9.swhph2cSQ74nkLQ75n3WSC5qgmggR9-_uHyyALbaDlQ"
}
}{
"message": "Password was succesfully updated"
}{
"errors": {
"user": [
"User is empty"
]
}
}