POST/api/v1/mfa/factors/:factorId/confirm确认 MFA 因素生效

以验证器生成的当前 TOTP 码确认待确认因素;确认后因素生效、参与登录校验。

Request

Headers

NameData TypeRequiredDescription
AuthorizationstringYes会话令牌认证,格式 `Bearer <sessionToken>`
Content-TypestringYes请求体内容类型(默认值 "application/json")
type RequestHeaders = {
  /** 会话令牌认证,格式 `Bearer <sessionToken>` */
  Authorization: string
  /** 请求体内容类型,默认值 "application/json" */
  Content-Type: string
}
{
  "Authorization": "Bearer st_7c1f9e05b28d4a63",
  "Content-Type": "application/json"
}

URL Parameters

Name Data Type Description
factorId string 待确认因素 ID

Body

NameData TypeRequiredDescription
codestringYes验证器当前 TOTP 码(6 位)
type RequestBody = {
  /** 验证器当前 TOTP 码(6 位) */
  code: string
}
{
  "code": "384127"
}

Response

Body

NameData TypeRequiredDescription
factorIdstringYes因素 ID
statusstringYes固定为 active
type ResponseBody = {
  /** 因素 ID */
  factorId: string
  /** 固定为 active */
  status: string
}
{
  "factorId": "01JD8SKH5N6P9W5XP9T4WDJ7U0C",
  "status": "active"
}

HTTP Code

HTTP Status Meaning Notes
200 成功 因素已生效
400 码错误 TOTP 码不正确

Response Code

响应使用统一信封 {id, code, messages, result},其 code 字段:

code Meaning Notes
0 成功 因素已生效
2204 MFA 码错误 TOTP 码不正确或因素不匹配

Examples

POST /api/v1/mfa/factors/01JD8SKH5N6P9W5XP9T4WDJ7U0C/confirm
Authorization: Bearer st_7c1f9e05b28d4a63
Content-Type: application/json

{
  "code": "384127"
}
{
  "id": "01JD8SKLL6N3M7N8",
  "code": 0,
  "messages": [],
  "result": { "factorId": "01JD8SKH5N6P9W5XP9T4WDJ7U0C", "status": "active" }
}