- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在尝试 aws cognito 用户池并在用户注册过程中堆积。我已经配置了我的用户池并正在执行注册方法,但我可以找到一种方法来获取 aws 服务返回的错误代码。这是我的用户池实例,工作正常:
let poolConfig = AWSCognitoIdentityUserPoolConfiguration(
clientId: userPool_clientId,
clientSecret: userPool_secret,
poolId: userPool_id)
AWSCognitoIdentityUserPool.registerCognitoIdentityUserPool(with: poolConfig,
forKey: userPoll_App)
userPool = AWSCognitoIdentityUserPool(forKey: userPoll_App)
然后,在我的 View Controller 中,我有一个带有 @IBAction 的按钮:
if userPool != nil {
let attName = AWSCognitoIdentityUserAttributeType()!
attName.name = "name"
attName.value = userNome
let attLast = AWSCognitoIdentityUserAttributeType()!
attLast.name = "family name"
attLast.value = userSobrenome
let attEmail = AWSCognitoIdentityUserAttributeType()!
attEmail.name = "email"
attEmail.value = userEmail
var result:Bool = false
userPool!.signUp(userNome,
password: userPwd,
userAttributes: [attName, attLast, attEmail],
validationData: nil).continue({(task:AWSTask!) in
if (task.error != nil) {
print (task.error!)
result = false
} else {
result = true
}
return nil
})
在该代码之后,我测试结果以查看它是真还是假,然后采取适当的措施。但是……
我在这个过程中遇到了不同的错误,我需要在开发时评估这些错误。例如,我遇到的第一个错误是因为我错误地配置了 AWS 区域。行!游戏开始!!但是第二个错误是因为用户告知的密码没有通过池的验证。在这种情况下,我想知道错误是因为验证过程并通知用户采取适当的操作。我不想在 iOS 应用程序中有这种逻辑。 task.error 对象只是提供了一个本地化的描述属性,它不是很有用。
顺便说一句:我使用的是 Swift 3.2、iOS 10.2、aws-ios-sdk2 和 Xcode 8。
最佳答案
我想扩展 behrooziAWS 的回答。
在 Swift 4 中,您可以将错误代码与 AWSCognitoIdentityProviderErrorType.TheErrorType.rawValue 等枚举相匹配。
这里有一个搜索错误类型的提示,只需键入“AWSErrorType”,Xcode 的自动完成功能就会显示所有枚举,然后您就可以浏览它们了。
这是我使用的代码。
AWSobject.AWSfunction().continueWith { task -> Any? in
if let err = task.error as NSError? {
switch err.code {
case: AWSCognitoIdentityProviderErrorType.userNotFound.rawValue:
// Handle case
default:
// Handle all other cases here
return nil
}
// Do stuff on success!
}
关于ios - 在 Swift-iOS 中,我如何在 AWS Cognito 中捕获用户身份验证错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41471039/
我目前在 AWS 上使用 Cognito 进行用户管理, 我希望能够与我的用户一起导入 CSV 以添加到项目中。有了基本信息我就可以成功添加用户了。 不过,我想直接在 CSV 中添加一个用户和一个关联
我正在使用 Cognito 提供的 Web UI 表单,以便用户通过 OAuth 流程登录我们的网站。 我们有一个用例,用户应该跨浏览器退出所有登录的 session 。 查看文档,似乎是 Admin
一个应用程序正在通过 Open ID Connect 协议(protocol)与 进行通信AWS 认知 , 连接到 ADFS ,通过 SAML 进行通信。 Cognito 本质上是“代理”ADFS 服
我们当前在尝试创建密码中包含空格字符的用户时遇到 InvalidParameterException。 有什么方法可以更新密码策略以启用此功能,这是错误还是预期行为? 最佳答案 Cognito 的密码
Cognito 用户池配置为用户使用他们的“电子邮件地址”来注册和登录。 如果用户使用其他人的电子邮件注册,那么该电子邮件将陷入未确认状态,所有者将无法正确使用它。 话虽如此,让我提供一个具有以下场景
我在 AWS Cognito 用户池中设置了一个 OpenID Connect 身份提供商。在浏览器中尝试此 URL 时: https:///oauth2/authorize?redirect_uri
我正在开发一个应用程序,我在其中使用 AWS Cognito 来存储用户数据。我正在努力了解如何管理 Cognito 的备份和灾难恢复方案! 以下是我的主要问题: 我想知道这些存储的用户数据的可用性如
用户在 Cognito 中更新电子邮件,Cognito 将电子邮件验证标志翻转为 false 并发送验证电子邮件。如果 Cognito 无法发送电子邮件或代码已过期,我将如何强制 Cognito 重新
有没有一种方法可以对Amazon Cognito用户池中的用户强制执行密码过期策略? 最佳答案 password policy似乎没有内置过期功能。您可以通过添加passwordUpdatedAt字段
我已使用连接到 Google 身份提供商的应用客户端设置了 Cognito 授权方。 “回调 URL”为 http://localhost而“退出 URL”是 http://localhost/log
我正在使用 Aws Cognito,但无法找到从 Cognito 登录页面中删除“注册”按钮的解决方案。谢谢。 Cognito 用户池提供了默认登录页面,其中包含忘记密码、登录和注册。但我想从该页面隐
这个问题在这里已经有了答案: Reference - What does this regex mean? (1 个回答) 4年前关闭。 我正在使用 AWS Cognito 对我的应用程序进行身份验证
我们正在使用 Cognito。一切都很好。我使用 AdminCreateUser API 添加了一个用户,他们收到了他们的临时密码。不幸的是,他们等了一个多月才登录,现在当他们尝试使用临时密码登录时,
我们使用 Cognito 托管 UI 和本地帐户登录以及少数 SAML 提供商。有一个选项可以自定义一些样式,但我正在寻找一些额外的东西。 添加自定义文本和指向外部网站的链接 - 例如条款和条件 SA
Amazon Cognito 会针对忘记密码请求发送一封验证电子邮件。如何使用个性化参数更新此验证电子邮件,使其包含以下参数:(用户名/电子邮件)。 最佳答案 您可以为自定义消息使用类似于下面的 la
我想创建一个允许用户注册的服务,但这些用户可以是团队或组织的一部分;就像任何其他服务一样,例如Slack、Trello、Google Apps 等。因此,这些用户需要从他们注册的上级团队或组织继承设置
如果激活验证功能,Amazon Cognito 会自动发送验证码。在我的项目中,有时我会添加用户(AWS Java SDK 中的注册功能)并通过 AdminConfirmSignup 自己验证它们,所
我正在使用 AWS Cognito 通过向用户的电子邮件发送验证链接来验证用户的电子邮件。用户点击链接后,默认的确认信息“您的注册已被确认!”显示。有没有办法自定义此消息? 谢谢! 最佳答案 目前(2
Cypress 有没有办法与 Cognito 集成?我有一个没有登录页面的应用程序,但使用来自另一个具有 Cognito 登录名的网站的 cookie。 (使用cookies) 无论如何,是否可以在不
每当我使用除以下内容之外的任何redirect_uri 将浏览器定向到 Cognito 注销端点时: http://localhost:63882/signin-oidc 我收到“redirect_m
我是一名优秀的程序员,十分优秀!