2019-12-15 16:21:43 +00:00
|
|
|
# Account login by username
|
2019-12-22 14:39:30 +00:00
|
|
|
|
2019-12-15 16:21:43 +00:00
|
|
|
## Introduction
|
2019-12-22 14:39:30 +00:00
|
|
|
|
2019-12-15 16:21:43 +00:00
|
|
|
This extension is intended for logging into user account on a server by username
|
|
|
|
|
|
|
|
## Message type identifiers
|
2019-12-22 14:39:30 +00:00
|
|
|
|
2019-12-15 16:21:43 +00:00
|
|
|
- `profile:login`
|
|
|
|
|
2019-12-26 13:41:23 +00:00
|
|
|
## Errors
|
2019-12-22 14:39:30 +00:00
|
|
|
|
2019-12-26 13:41:23 +00:00
|
|
|
- Ratelimit system: enabled
|
2019-12-26 13:39:50 +00:00
|
|
|
- `invalid_creds`: user ID/password isn't valid
|
2019-12-15 16:21:43 +00:00
|
|
|
|
|
|
|
## Use cases
|
2019-12-22 14:39:30 +00:00
|
|
|
|
2019-12-29 14:40:17 +00:00
|
|
|
- Request:
|
2019-12-22 14:39:30 +00:00
|
|
|
|
2019-12-15 16:21:43 +00:00
|
|
|
```json
|
|
|
|
{
|
|
|
|
"id": "abcd",
|
|
|
|
"type": "profile:login",
|
|
|
|
"to": "cadmium.org",
|
|
|
|
"payload": {
|
|
|
|
"username": "juliet",
|
|
|
|
"password": "romeo1"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2019-12-29 14:40:17 +00:00
|
|
|
- Response:
|
2019-12-22 14:39:30 +00:00
|
|
|
|
2019-12-15 16:21:43 +00:00
|
|
|
```json
|
|
|
|
{
|
|
|
|
"id": "abcd",
|
|
|
|
"type": "profile:login",
|
|
|
|
"from": "cadmium.org",
|
|
|
|
"ok": true,
|
|
|
|
"payload": {
|
|
|
|
"authToken": "3b5135a5-aff5-4396-a629-a254f383e82f",
|
|
|
|
"deviceID": "ABCDEFG"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2019-12-29 14:40:17 +00:00
|
|
|
- Error response:
|
2019-12-22 14:39:30 +00:00
|
|
|
|
2019-12-15 16:21:43 +00:00
|
|
|
```json
|
|
|
|
{
|
|
|
|
"id": "abcd",
|
|
|
|
"type": "profile:login",
|
|
|
|
"from": "cadmium.org",
|
|
|
|
"ok": false,
|
|
|
|
"payload": {
|
2019-12-26 13:39:50 +00:00
|
|
|
"errCode": "invalid_creds",
|
2019-12-15 16:21:43 +00:00
|
|
|
"errText": "Username/password isn't valid"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Business Rules
|
2019-12-22 14:39:30 +00:00
|
|
|
|
2019-12-26 13:41:23 +00:00
|
|
|
None.
|
2019-12-15 16:21:43 +00:00
|
|
|
|
|
|
|
## JSON Schema
|
2019-12-22 14:39:30 +00:00
|
|
|
|
|
|
|
### Payload
|
2019-12-15 16:21:43 +00:00
|
|
|
|
|
|
|
- Request:
|
2019-12-22 14:39:30 +00:00
|
|
|
|
2019-12-15 16:21:43 +00:00
|
|
|
```typescript
|
|
|
|
interface LoginRequestPayload {
|
|
|
|
/**
|
2019-12-29 14:40:17 +00:00
|
|
|
* The username of account which user wants to login (can be omit if we set thirdPID)
|
2019-12-15 16:21:43 +00:00
|
|
|
*/
|
|
|
|
username: string,
|
2019-12-22 14:39:30 +00:00
|
|
|
|
2019-12-29 14:40:17 +00:00
|
|
|
/**
|
|
|
|
* Third party ID which have user (can be omit if we set username)
|
|
|
|
*/
|
|
|
|
thirdPID: string,
|
2019-12-22 14:39:30 +00:00
|
|
|
|
2019-12-15 16:21:43 +00:00
|
|
|
/**
|
|
|
|
* Password of new account
|
|
|
|
*/
|
|
|
|
password: string
|
|
|
|
}
|
|
|
|
```
|
2019-12-22 14:39:30 +00:00
|
|
|
|
2019-12-15 16:21:43 +00:00
|
|
|
- Response:
|
2019-12-22 14:39:30 +00:00
|
|
|
|
2019-12-15 16:21:43 +00:00
|
|
|
```typescript
|
|
|
|
interface LoginResponsePayload {
|
|
|
|
/**
|
2019-12-29 13:01:35 +00:00
|
|
|
* Authentication token which required for various user actions (static SHA256 hash string from 4096 random characters)
|
2019-12-15 16:21:43 +00:00
|
|
|
*/
|
|
|
|
authToken: string,
|
2019-12-22 14:39:30 +00:00
|
|
|
|
|
|
|
|
2019-12-15 16:21:43 +00:00
|
|
|
/**
|
|
|
|
* Identifier of new user device (created by this login action)
|
|
|
|
*/
|
|
|
|
deviceID: string
|
|
|
|
}
|
2019-12-29 13:01:35 +00:00
|
|
|
```
|