Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

...

...

...

Table of Contents
Specification


Apiary
Status
titlepatch
mithril/api/users/{user_id}/authentication_factors{2fa_id}/actions/setrequest_factor
Scopeauthentication_factor:setrequest_factor

Purpose

Update value of factor (after RESET logical status of 2fa)Collect factor from user,  save factor & type into token, create OTP for approval factor.

Request parameters

  • token
  • user_id
  • 2fa_id
  • new_factorfactor
  • type


Logic WS

  • Validate token & scope
  • Validate user_id FKValidate 2fa_id FK
  • Get 2FA item by 2fa_id  for $.type  for non-blocked user by $.user_id

    Code Block
    languagesql
    SELECT *
    FROM authentication_factors AS 2FA
    	INNER JOIN user AS U
    		ON 2FA.user_id = U.id
    WHERE 
    	U.id = $.user_id
    		AND 2FA.idtype = $.2fa_idtype
    		AND U.is_active = TRUE
    		AND U.is_blocked = FALSE
    • If  (exist 2FA item for user) AND (token_type = access_token_type) AND (2FA.factor <> "" AND  2FA.factor <> NULL) - update 2FA item (set values) to logical status = ACTIVE :
      • 2FA.factor = new_factor
      • 2FA.update_at = now()
    • If  (exist 2FA item for user) AND (token_type = 2fa_access_token_type) AND (2FA.factor = "" OR  2FA.factor = NULL) - update 2FA item (set values) to logical status = ACTIVE :
      • 2FA.factor = new_factor
      • 2FA.update_at = now()
    • Else return 401 error 
  • Return 200
  • ...

Response

  • 200 if 2FA successful set new.factor  + 2FA_object_view
  • 4xx in other case