cadmium-docs-legacy/protocol-spec/account-registration.md

129 lines
2.2 KiB
Markdown
Raw Normal View History

# Account registration
2019-12-16 13:53:37 +00:00
## Introduction
2019-12-16 13:53:37 +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`
## 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
## 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
- Client:
2019-12-16 13:53:37 +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"},
],
"password": "romeo1"
}
}
```
2019-12-26 13:39:50 +00:00
- Server:
2019-12-16 13:53:37 +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:
```json
{
"id": "abcd",
"type": "profile:register",
"from": "cadmium.org",
"ok": false,
"payload": {
2019-12-26 13:39:50 +00:00
"errCode": "id_exists",
"errText": "Username/email/msisdn already taken"
}
}
```
## Business Rules
2019-12-16 13:53:37 +00:00
2019-12-26 13:41:23 +00:00
None.
## JSON Schema
2019-12-16 13:53:37 +00:00
### Payload
- Request:
2019-12-16 13:53:37 +00:00
```typescript
interface RegistrationRequestPayload {
/**
* The username that the user wants to register
*/
2019-12-29 13:01:35 +00:00
username?: string,
/**
* 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
}
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
- Response:
2019-12-16 13:53:37 +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-16 13:53:37 +00:00
```