'username'값이 제약 조건을 충족시키지 못함 : 구성원의 길이가 1 이상이어야하며 'username'값이 제약 조건을 충족하지 못했습니다. 구성원이 정규 표현식 패턴을 충족해야합니다 : [\ p {L} \ p {M} \ p {S} \ p {N} \ p {P}] + ";
처음 계정을 만들면 사용자 스토리 보드 확인으로 이동하여 사용자 이름과 코드를 입력해야합니다. 그러나 기술적으로 확인되지 않은 계정으로 로그인했기 때문에 사용자 이름은 이미 입력되었습니다. 그러나 이것은 확인되지 않은 계정으로 로그인 할 수있는 유일한 시간입니다 (다른 해결 방법이없는 한). 따라서 확인 사용자 컨 트롤러로 다시 돌아 가려는 경우 입력 한 사용자 이름이 아니라 로그인 한 사용자의 사용자 이름을 코드에 사용하기 때문에 단순히 사용자 이름을 입력 할 수 없습니다. 이 문제를 해결하는 방법은 사용자 이름과 코드를 입력 한 다음 계정을 확인하기 만하면됩니다.
이 스택 내 첫 번째 게시물 그래서 여기 내 최고의 대답입니다 : 방법에
...
override func viewDidLoad() {
변화 ...에
self.username.text = self.user!.username
....
if self.user?.username == "" || self.user == nil {
print("user is nil")
} else {
self.username.text = self.user!.username
}
.... 그리고 다음을 삽입하십시오 당신의 poolID와 당신의 "Confirm"메쏘드와 당신 자신의 SEGUE를위한 @IBAction에; 코드 값이 비어과 "self.user? .confirmSignUp"방법 이전 인 경우 확인 후 ...이 도움이
if self.user?.username == "" || self.user == nil {
// change the poolid to yours
let pool = AWSCognitoIdentityUserPool(fenter code hereorKey: userPoolID)
// change the "username" title to whatever corresponds to the text field identifier you are using
let user = pool.getUser((self.username?.text)!)
user.confirmSignUp(self.code.text!, forceAliasCreation: true).continueWith {[weak self] (task: AWSTask) -> AnyObject? in
guard let strongSelf = self else { return nil }
DispatchQueue.main.async(execute: {
if let error = task.error as? NSError {
let alertController = UIAlertController(title: error.userInfo["__type"] as? String, message: error.userInfo["message"] as? String, preferredStyle: .alert)
let okAction = UIAlertAction(title: "Ok", style: .default, handler: nil)
alertController.addAction(okAction)
strongSelf.present(alertController, animated: true, completion: nil)
} else {
// Change the segue identifier to yours
strongSelf.performSegue(withIdentifier: "confirmedUserSegue", sender:sender)
}
})
return nil
}
}
희망을 삽입! ...
다른 문에 아마존 예제 코드의
if self.user?.username == "" || self.user == nil {
let pool = AWSCognitoIdentityUserPool(forKey: userPoolID)
let user = pool.getUser((self.username?.text)!)
user.resendConfirmationCode().continueWith {[weak self] (task: AWSTask) -> AnyObject? in
guard let _ = self else { return nil }
DispatchQueue.main.async(execute: {
if let error = task.error as? NSError {
let alertController = UIAlertController(title: error.userInfo["__type"] as? String,
message: error.userInfo["message"] as? String,
preferredStyle: .alert)
let okAction = UIAlertAction(title: "Ok", style: .default, handler: nil)
alertController.addAction(okAction)
self?.present(alertController, animated: true, completion: nil)
} else if let result = task.result {
let alertController = UIAlertController(title: "Code Resent",
message: "Code resent to \(result.codeDeliveryDetails?.destination!)",
preferredStyle: .alert)
let okAction = UIAlertAction(title: "Ok", style: .default, handler: nil)
alertController.addAction(okAction)
self?.present(alertController, animated: true, completion: nil)
}
})
return nil
}
} else
... 나머지 :
가 할, 같은 일을 재전송 코드를 해결하려면