ЕСОЗ - публічна документація

Create User 2FA

Specification

Apiary
POSTmithril/users/{user_id}/authentication_factors
Scopeauthentication_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 

    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
        1. user_id = $.user_id
        2. type = $.type
        3. factor = NULL
        4. is_active = TRUE
        5. inserted_at = now()
        6. update_at = now()
      •  Return 201
    • If exist 2FA with $.type -  return 409 error "authentication_factor with such type are exist" 

Response

  • 201 if 2FA item created successful 
  • 4xx in other case

ЕСОЗ - публічна документація