2019-12-15 16:04:30 +00:00
|
|
|
# Account registration
|
2019-12-16 13:53:37 +00:00
|
|
|
|
2019-12-15 16:04:30 +00:00
|
|
|
## Introduction
|
2019-12-16 13:53:37 +00:00
|
|
|
|
2019-12-15 16:04:30 +00:00
|
|
|
This extension is intended for creating user accounts on a server
|
|
|
|
|
|
|
|
## Message type identifiers
|
2019-12-16 13:53:37 +00:00
|
|
|
|
|
|
|
- `profile:register`
|
2019-12-15 16:04:30 +00:00
|
|
|
|
2019-12-26 14:39:19 +00:00
|
|
|
## Errors
|
2019-12-16 13:53:37 +00:00
|
|
|
|
2019-12-26 13:41:23 +00:00
|
|
|
- Ratelimit system: enabled
|
2019-12-26 13:39:50 +00:00
|
|
|
- `id_exists`: username/third party ID already taken
|
|
|
|
- `reg_disabled`: registration isn't allowed on a server
|
2019-12-15 16:04:30 +00:00
|
|
|
|
|
|
|
## Use cases
|
2019-12-16 13:53:37 +00:00
|
|
|
|
2019-12-29 13:01:35 +00:00
|
|
|
### Basic registration flow
|
2019-12-26 13:39:50 +00:00
|
|
|
|
2019-12-29 14:40:17 +00:00
|
|
|
`// TODO: introduce email/msisdn confirmation which prevents spam attacks`
|
|
|
|
|
2019-12-26 13:39:50 +00:00
|
|
|
- Client:
|
2019-12-16 13:53:37 +00:00
|
|
|
|
2019-12-15 16:04:30 +00:00
|
|
|
```json
|
|
|
|
{
|
|
|
|
"id": "abcd",
|
|
|
|
"type": "profile:register",
|
|
|
|
"to": "cadmium.org",
|
|
|
|
"payload": {
|
|
|
|
"username": "juliet",
|
|
|
|
"thirdPIDs": [
|
|
|
|
{"type":"email", "value":"juliet@capulett.com"},
|
|
|
|
{"type":"msisdn", "value":"+1234567890"},
|
|
|
|
],
|
2019-12-29 14:40:17 +00:00
|
|
|
"password": "romeo1",
|
|
|
|
"loginOnSuccess": false
|
2019-12-15 16:04:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2019-12-26 13:39:50 +00:00
|
|
|
- Server:
|
2019-12-16 13:53:37 +00:00
|
|
|
|
2019-12-15 16:04:30 +00:00
|
|
|
```json
|
|
|
|
{
|
|
|
|
"id": "abcd",
|
|
|
|
"type": "profile:register",
|
|
|
|
"from": "cadmium.org",
|
|
|
|
"ok": true,
|
|
|
|
"payload": {
|
|
|
|
"userID": "@juliet@cadmium.org"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2019-12-22 14:39:30 +00:00
|
|
|
- Error response:
|
|
|
|
|
2019-12-15 16:04:30 +00:00
|
|
|
```json
|
|
|
|
{
|
|
|
|
"id": "abcd",
|
|
|
|
"type": "profile:register",
|
|
|
|
"from": "cadmium.org",
|
|
|
|
"ok": false,
|
|
|
|
"payload": {
|
2020-07-16 08:04:56 +00:00
|
|
|
"errID": "id_exists",
|
2019-12-26 13:39:50 +00:00
|
|
|
"errText": "Username/email/msisdn already taken"
|
2019-12-15 16:04:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Business Rules
|
2019-12-16 13:53:37 +00:00
|
|
|
|
2019-12-26 13:41:23 +00:00
|
|
|
None.
|
2019-12-15 16:04:30 +00:00
|
|
|
|
|
|
|
## JSON Schema
|
2019-12-16 13:53:37 +00:00
|
|
|
|
|
|
|
### Payload
|
2019-12-15 16:04:30 +00:00
|
|
|
|
|
|
|
- Request:
|
2019-12-16 13:53:37 +00:00
|
|
|
|
2019-12-15 16:04:30 +00:00
|
|
|
```typescript
|
|
|
|
interface RegistrationRequestPayload {
|
|
|
|
/**
|
|
|
|
* The username that the user wants to register
|
|
|
|
*/
|
2019-12-29 13:01:35 +00:00
|
|
|
username?: string,
|
2019-12-15 16:04:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Array of user third party IDs (email and/or MSISDN)
|
|
|
|
*/
|
|
|
|
thirdPIDs: ThirdPartyID[],
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Password of new account
|
|
|
|
*/
|
2019-12-29 13:01:35 +00:00
|
|
|
password: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Login to freshly created user account when registration will be completed
|
|
|
|
*/
|
|
|
|
loginOnSuccess: boolean
|
2019-12-15 16:04:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface ThirdPartyID {
|
|
|
|
/**
|
|
|
|
* Type of third party ID
|
|
|
|
*/
|
|
|
|
type: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* String contains third party ID. Examples: "juliet@capulett.com", "+1234567890".
|
|
|
|
*/
|
|
|
|
value: string
|
|
|
|
}
|
|
|
|
```
|
2019-12-16 13:53:37 +00:00
|
|
|
|
2019-12-15 16:04:30 +00:00
|
|
|
- Response:
|
2019-12-16 13:53:37 +00:00
|
|
|
|
2019-12-15 16:04:30 +00:00
|
|
|
```typescript
|
|
|
|
interface RegistrationResponsePayload {
|
|
|
|
/**
|
|
|
|
* ID of user (Username in priority. If we haven't username, then we put to this field one of user's third party IDs)
|
|
|
|
*/
|
2019-12-29 13:01:35 +00:00
|
|
|
userID: EntityID,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Property with login payload (can be omit if property loginOnSuccess wasn't indicated true in RegistrationRequestPayload)
|
|
|
|
*/
|
|
|
|
loginPayload?: LoginResponsePayload
|
2019-12-15 16:04:30 +00:00
|
|
|
}
|
2019-12-16 13:53:37 +00:00
|
|
|
```
|