Mangogo 营业厅Mangogo 营业厅
首页API 参考Skills插件

3.6 邮箱绑定

POST/api/oauth/email/bind/code

3.6 邮箱绑定

邮箱绑定

接口地址: POST /api/oauth/email/bind/code

权限要求: 🔐 需要登录(User权限)

描述: 使用邮箱验证码绑定邮箱

请求头:

token: {access_token}

请求头说明:

  • token (必填): 访问令牌

请求参数:

  • email (string, 必填): 新邮箱
  • code (string, 必填): 新邮箱验证码(type 为 bind_change_email)

请求示例:

curl -X POST "https://your-domain.com/api/oauth/email/bind/code" \  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \  -H "Content-Type: application/json" \  -d '{    "email": "user@example.com",    "code": "123456"  }'

实现逻辑:

  1. 根据新邮箱和新邮箱验证码查询 email_verifications 表,条件为:
    • email = 新邮箱
    • type = bind_change_email
    • is_used = false
    • expired_at > 当前时间(未过期)
  2. 如果查询结果存在且验证码匹配,则验证通过
  3. 验证通过后,将该邮箱的所有验证码的 is_used 都设置为 true
  4. 检查新邮箱是否已被其他用户使用
  5. 更新当前用户的邮箱
  6. 返回绑定成功

返回数据:

{  "success": true,  "message": ""}