Created User Login API (markdown)

Tom Bloor 2017-04-22 18:20:02 +01:00
parent 615b28a45b
commit 7a96278830

60
User-Login-API.md Normal file

@ -0,0 +1,60 @@
# User Login API
_Last Updated 2017-04-22_
## `POST /api/login`
Takes a `application/json` payload.
### Request JSON
```
{
email : <login email>,
password : <login password>
}
```
### Response JSON
#### Success
Response code of `200 OK`
```
{
success : true,
session_key : <session_key>
}
```
#### Failure
If something is missing from the request, or is invalid, you will get a response code of `400 BAD REQUEST` and the following:
```
{
success : false,
message : <error message>
error : <error type>
}
```
If the username or email was incorrect, you will get a `401 UNAUTHORISED` and the following:
```
{
success : false,
message : 'Email or password is invalid',
error : 'login_fail'
}
If there was a server error, you will get a `500 SERVER ERROR` and possibly the following:
```
{
success : false,
message : 'An unknown error occurred when logging in'
error : 'server_error'
}
```