api_user_registration /

Filename Size Date modified Message
commands
config
controllers
forms
mail
models
7 B
163 B
6.0 KB

Регистрация

Registration — Регистация нового пользователя и получения письма с кодом активации пользователя. Активицация пользователя и получение Access Token для дальнейшей работы

Registration

Регистрация пользователя в системе происходит в два этапа.

  • Регистрация пользователя с отправкой e-mail (login) на почтовый ящик c ссылкой для активизазии аккаунта.

  • Активицация пользователя и получение Access Token для дальнейшей работы

1. Регистрация пользователя

POST user/registration

POST data

{
    "email": "user_email@somehostname.com",
    "password": "some_password",
    "password_repeat": "some_password",
}

Пользователь создан. На e-mail отправлено письмо с кодом активизации.

STATUS 204

{
    "uid": "52fac8f1-b9a7-51a6-be65-6084669302ef",
    "login": "user_email@somehostname.com",
}

Типы сообщений об ошибки валидации

STATUS 422

[
  {
    "field": "email",
    "message": "Email cannot be blank."
  },
  {
    "field": "password",
    "message": "Password cannot be blank."
  },
  {
    "field": "password_repeat",
    "message": "Password_repeat cannot be blank."
  }
]

STATUS 422

[
  {
    "field": "email",
    "message": "Email is not a valid email address."
  }
]

STATUS 422

[
  {
    "field": "email",
    "message": "This email address has already been taken"
  }
]

STATUS 422

[
  {
    "field": "password_repeat",
    "message": "Password Repeat must be repeated exactly."
  }
]

2. Активация пользователя

GET user/activate?email=hairat@nnm.com&code=some_code_here

GET data

{
    "email": "user_email@somehostname.com",
    "code": "code_from_email",
}

Пользователь активирован

STATUS 200

{
  "user": {
    "uid": "b3d7311d-c15c-49f9-a11b-80be14c105dd",
    "login": "hairat@nnm.com"
  },
  "token": {
    "id": "ab9c32fcbc3ebe5eb757d723868dcfe3",
    "user_uid": "b3d7311d-c15c-49f9-a11b-80be14c105dd",
    "r": 1,
    "w": 1,
    "ip": "192.168.78.93",
    "la": 1438942009,
    "d": {
      "device": "",
      "login": "hairat@nnm.com"
    },
    "ttl": 604800
  }
}

Типы сообщений об ошибки валидации

STATUS 422

[
  {
    "field": "email",
    "message": "Email cannot be blank."
  },
  {
    "field": "code",
    "message": "Code cannot be blank."
  }
]

STATUS 422

[
  {
    "field": "email",
    "message": "Email is not a valid email address."
  }
]

STATUS 422

[
  {
    "field": "email",
    "message": "User have been activated. Do not have to be activated again."
  }
]

STATUS 422

[
  {
    "field": "email",
    "message": "User with this email does not exist. Please register first."
  }
]

STATUS 422

[
  {
    "field": "code",
    "message": "Activation code expired or incorrect."
  }
]

Workflow user create /activate

1. User create

1.1 Configuration

POST user/registration' => jtapp/user/registration

1.2 Action

controller/UserController actionRegistration()

1.3 Validation form

forms/RegistrationForm rules()

1.4 Main method in model

models/User newUserCreate() 
models/User putTaskSendEmailWithLink2ActiveCode() 

2. Send e-mail with activation link

commands/SendEmailWithActivateLinkController actionIndex()

3. User activate

3.1 Configuration

config/web.php 
'GET user/activate' => 'jtapp/user/activate',

3.2 Action

controller/UserController actionActivate()

3.3 Validation form

forms/ActivateForm rules() 

3.4 Main method in model

models/User activateUser()