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)" )
- self?.pool?.currentUser()?.getSession(userNameValue, password: passwordValue, validationData: nil).continueOnSuccessWith(executor: AWSExecutor.mainThread(), block: { (task) -> Any? in
- if(task.error == nil){
- print("user is logged in")
- getUserId()
- let myTask = task.result
- } else{
- print("There is an error in the signin process")
- }
- return nil
- })
- }
- func getUserId(){
- print("Get userId func called")
- self.pool?.currentUser()?.getDetails().continueWith(block: { (task) -> Any? in
- 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 nil}
- guard let phoneNumberVerified = attributes![1].value as? String else { return nil }
- guard let phoneNumber = attributes![2].value as? String else { return nil }
- print("userId: \(userId)")
- }
- } else{
- print("There is an error in the signin process")
- print("Error: \(task.error)")
- }
- return nil
- }, cancellationToken: nil)
- }
Add Comment
Please, Sign In to add comment