Table of Contents |
---|
Apiary | |||||||
| mithril/users/{user_id}/authentication_factors | ||||||
Scope | authentication_factor:write |
Purpose
Create new 2FA item for user.
Request parameters
- user_id
- type
Logic WS
- Validate $.token
- Get user by user_id
- Validate user id & user status
- Validate user `is_blocked` flag
- if is_blocked = TRUE
- return 4xx - "User blocked" (!!! TBD)
Validate existing 2FA item with $.type user
Code Block language sql SELECT * FROM authentication_factors AS 2FA WHERE 2FA.user_id = $.user_id AND 2FA.type = $.type
- If not exist 2FA item with $.type
- Insert new record in `authentication_factors` with logical status = RESET
- user_id = $.user_id
- type = $.type
- factor = NULL
- is_active = TRUE
- inserted_at = now()
- update_at = now()
- Return 201
- Insert new record in `authentication_factors` with logical status = RESET
- If exist 2FA with $.type - return 409 error "authentication_factor with such type are exist"
- If not exist 2FA item with $.type
Response
- 201 if 2FA item created successful
- 4xx in other case