如果更改密码时旧密码不匹配,我应该使用什么状态代码?

What status code should I use if old password doesn't match while changing password?

在后端,我有一个经过身份验证的用户重置密码的逻辑。我将旧密码和新密码作为参数。如果旧密码不匹配,那么他们会得到一个错误,但我找不到合适的状态代码。

认证中间件失败时发送401 Unauthorized,导致我401冲突无法使用。我想,即使不使用,在这种情况下 401 也不是最合适的状态

403 Forbidden

the server understood the request but refuses to authorize it. A server that wishes to make public why the request has been forbidden can describe that reason in the response payload (if any).

请记住,status-codes 是元数据,就像 headers 一样:它们是标准化形式的数据,允许通用组件理解 requests/responses 的语义,而不需要这些组件理解 message-body.

的细节