0
我已成功實施Cognito for iOS。我已決定在3個階段來分割認證過程:Cognito用戶確認有未確認的狀態
- 的註冊
- 確認與代碼
- 登入
對於代碼確認我有這一段代碼:
func sendCode() {
self.pool = AWSCognitoIdentityUserPool(forKey: AWSCognitoUserPoolsSignInProviderKey)
let userForCode = self.pool?.getUser(self.emailTextField.text!)
// Bizarre ce test ne passe pas pourtant le client est confirmé dans Cognito...
if (userForCode?.confirmedStatus != AWSCognitoIdentityUserStatus.confirmed) {
userForCode?.confirmSignUp(confirmCodeTextField.text!, forceAliasCreation: true).continueWith { [weak self] (task) -> Any? in
DispatchQueue.main.async {
if let error = task.error as? NSError {
print("erreurCode : \(error.userInfo["message"])")
} else if let result = task.result {
print("client créé confirmé")
}
}
return nil
}
}
}
我從userPool得到一個用戶,我想詢問用戶是否是確認代碼,如果他的acco unt尚未確認,因此對userCode.confirmedStatus進行了測試。不幸的是,即使用戶在Cognito AWS控制檯中具有確認狀態,測試也總是如此。