Skip to content

Auth Hooks: 'Invalid payload' when anonymous users attempt phone changes

当负载中包含匿名用户的 new_phone 时,在认证钩子中会出现“发送到钩子的负载无效”错误(500)。

🌐 An 'Invalid payload sent to hook' error (500) occurs in Auth hooks when the payload includes new_phone for an anonymous user.

这为什么会发生? #

🌐 Why does this happen?

这个错误出现是因为匿名用户没有现有的电话号码可以修改。客户端应用尝试对这样的用户执行 phone_change 会导致无效操作。new_phone 字段只应该在由已认证用户发起的 phone_change 流程中出现。

🌐 This error arises because anonymous users do not have an existing phone number to modify. Client application logic attempting a phone_change for such users results in an invalid operation. The new_phone field should only be present during a phone_change flow initiated by an authenticated user.

如何避免这个问题 #

🌐 How to avoid this issue

优化你的客户端应用逻辑,以防止这种错误的负载结构:

🌐 Refine your client application logic to prevent this incorrect payload structure:

  • 区分匿名用户和已认证用户的手机更新和登录流程。
  • 确保只有在经过身份验证的用户启动 phone_change 流程时才传输 new_phone
  • 对匿名用户更新进行不同处理,以避免在载荷中发送 new_phone