Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func signIn(createdUsernameValue: String, passwordValue: String){
- // Signin the user
- let authDetails = AWSCognitoIdentityPasswordAuthenticationDetails(username: createdUsernameValue, password: passwordValue)
- self?.passwordAuthenticationCompletion?.set(result: authDetails)
- self?.user = self?.pool?.currentUser()
- print("self.user :\(self?.user)" )
- if (self.user == nil) {
- self.user = self.pool?.currentUser()
- }
- refresh()
- }
- func refresh() {
- self.user?.getDetails().continueOnSuccessWith { (task) -> AnyObject? in
- DispatchQueue.main.async(execute: {
- if(task.error == nil){
- print("user is logged in")
- self.response = task.result
- if let response = self.response {
- let attributes = response.userAttributes
- guard let userId = attributes![0].value as? String else { return }
- guard let phoneNumberVerified = attributes![1].value as? String else { return }
- guard let phoneNumber = attributes![2].value as? String else { return }
- print("userId: \(userId)")
- }
- } else{
- print("There is an error in the signin process")
- print("Error: \(task.error)")
- }
- })
- return nil
- }
- }
Add Comment
Please, Sign In to add comment