Guest User

Untitled

a guest
Feb 9th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. // MARK: LoginViewController
  2.  
  3. class LoginViewController: UIViewController, AuthenticationSessionDelegate {
  4.  
  5. func login(with username: String,
  6. password: String) {
  7. let authenticationSession = AuthenticationSession()
  8. authenticationSession.delegate = self
  9. authenticationSession.performLogin(with: username,
  10. password: password)
  11. }
  12.  
  13. // MARK: AuthenticationSessionDelegate Methods
  14.  
  15. func authenticationSession(_ authenticationSession: AuthenticationSession, didLoginWith userIdentifier: String) {
  16. // Handle the login with userIdentifier
  17. }
  18. }
  19.  
  20. // MARK: AuthenticationSessionDelegate
  21.  
  22. protocol AuthenticationSessionDelegate: class {
  23. func authenticationSession(_ authenticationSession: AuthenticationSession, didLoginWith userIdentifier: String)
  24. }
  25.  
  26. // MARK: AuthenticationSession
  27.  
  28. class AuthenticationSession {
  29.  
  30. var delegate: AuthenticationSessionDelegate?
  31.  
  32. func performLogin(with username: String,
  33. password: String) {
  34. let userIdentifier = "12345" //Service.login(username, password)
  35. delegate?.authenticationSession(self, didLoginWith: userIdentifier)
  36. }
  37. }
Add Comment
Please, Sign In to add comment