如何确定哪个是正确的认知错误

How to figure which is the right cognito error

假设我想创建一个图书馆应用程序并使用 AWS Cognito 管理用户订阅。我的 AWS Cognito 用户池中注册了以下用户

 email: abc@abc.abc
 psw: 123456

我希望填充不同的错误,例如

我面临的问题 - 似乎 AWS cognito returns NotAuthorizedException 当用户没有注册时以及他注册时刚打错字

有没有办法区分这两个用例? 根据 AWS(https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminListUserAuthEvents.html) 这些场景有不同的错误 NotAuthorizedExceptionInvalidParameterExceptionUserNotFoundException 但由于某种原因我只得到一个 NotAuthorizedException

有人可以指教

花了一些时间才弄明白这一点。 截至 2021 年 2 月,当创建用户池 PreventUserExistenceErrors 设置为 ENABLED 时,无论出于何种原因,此结果都将所有错误显示为一般 NotAuthorizedException 错误。

如果我们想在用户不存在和用户输入错误时收到不同的错误,那么您必须将 PreventUserExistenceErrors 更改为 LEGACY 这是如何:

  1. 打开 Cognito 仪表板
  2. select 您的用户群
  3. 转到 AppClient --> 显示详细信息 --> 安全配置 --> 防止用户存在错误更改为 Legacy 并保存。