Guest User

Untitled

a guest
Dec 12th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. func signIn(createdUsernameValue: String, passwordValue: String){
  2. // Signin the user
  3. let authDetails = AWSCognitoIdentityPasswordAuthenticationDetails(username: createdUsernameValue, password: passwordValue)
  4. self?.passwordAuthenticationCompletion?.set(result: authDetails)
  5. self?.user = self?.pool?.currentUser()
  6.  
  7. print("self.user :\(self?.user)" )
  8.  
  9. if (self.user == nil) {
  10. self.user = self.pool?.currentUser()
  11. }
  12. refresh()
  13. }
  14.  
  15.  
  16. func refresh() {
  17. self.user?.getDetails().continueOnSuccessWith { (task) -> AnyObject? in
  18. DispatchQueue.main.async(execute: {
  19. if(task.error == nil){
  20. print("user is logged in")
  21. self.response = task.result
  22. if let response = self.response {
  23. let attributes = response.userAttributes
  24.  
  25. guard let userId = attributes![0].value as? String else { return }
  26. guard let phoneNumberVerified = attributes![1].value as? String else { return }
  27. guard let phoneNumber = attributes![2].value as? String else { return }
  28.  
  29. print("userId: \(userId)")
  30. }
  31.  
  32. } else{
  33. print("There is an error in the signin process")
  34. print("Error: \(task.error)")
  35. }
  36. })
  37.  
  38. return nil
  39. }
  40. }
Add Comment
Please, Sign In to add comment