gpt4 book ai didi

http - 一次只能登录 1 响应代码

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:24:41 24 4
gpt4 key购买 nike

我正在编写一个只允许用户同时从 1 个客户端登录的系统。

因此:如果用户在 Phone 1 上登录(使用访问 token 1)并且用户抓取 Phone 2 再次登录(生成访问 token 2),我系统上的下一个 API 将被调用并返回错误代码。

现在这个错误代码将是 401。

一旦客户端检测到 401 响应,用户将被发送回登录页面,并会显示一条警报,告知用户该帐户已从另一台设备访问。

401 是用于此的正确错误代码吗?

最佳答案

401 错误代码表示未授权。换句话说,如果用户尚未访问应用程序并使用无效凭据,将返回相同的错误。

我建议您使用 403 Forbidden:

403 FORBIDDEN The server understood the request but refuses to authorize it.

或者409冲突:

409 CONFLICT The request could not be completed due to a conflict with the current state of the target resource. This code is used in situations where the user might be able to resolve the conflict and resubmit the request.

关于http - 一次只能登录 1 响应代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45273490/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com