Advertisement
lcolli98

LoginViewController.swift

Feb 24th, 2020
409
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 1.99 KB | None | 0 0
  1. //
  2. //  LoginViewController.swift
  3. //  AeroBuddy
  4. //
  5. //  Created by Luke Collister on 28/09/2019.
  6. //  Copyright © 2019 Luke Collister. All rights reserved.
  7. //
  8.  
  9.  
  10. import UIKit
  11.  
  12. class LoginViewController: UIViewController {
  13.  
  14.     @IBOutlet var email_input: UITextField!
  15.     @IBOutlet var password_input: UITextField!
  16.     //let navigationController = UINavigationController()
  17.    
  18.     // Make method in viewDidLoad to check if the current credentials are set, if so login without having to press the button
  19.     override func viewDidLoad() {
  20.         super.viewDidLoad()
  21.        
  22.         if (ServHandler.shared.isLoggedIn()) {
  23.             // User is logged in so segue to AC VC
  24.             DispatchQueue.main.async {
  25.                 self.present(ServHandler.shared.acVC, animated: true, completion: nil)
  26.             }
  27.         }
  28.         else {
  29.             // Authentication failed - oops!
  30.             // Do something about it.
  31.             print("B")
  32.         }
  33.     }
  34.  
  35.     @IBAction func login(_ sender: UIButton) {
  36.         ServHandler.shared.checkCredentials(password: password_input!.text!, for: email_input!.text!){ (result: Bool) -> Void in
  37.             if (result) {
  38.                 DispatchQueue.main.async {
  39.                     self.present(ServHandler.shared.acVC, animated: true, completion: nil)
  40.                 }
  41.             }
  42.             else {
  43.                 // Authentication failed - oops!
  44.                 // Do something about it.
  45.             }
  46.         }
  47.     }
  48.    
  49.    
  50.     @IBAction func guestLogin(_ sender: Any) {
  51.         ServHandler.shared.checkCredentials(password: "password", for: "ksc@ksc.me"){ (result: Bool) -> Void in
  52.             if (result) {
  53.                 DispatchQueue.main.async {
  54.                     self.present(ServHandler.shared.acVC, animated: true, completion: nil)
  55.                 }
  56.             }
  57.             else {
  58.                 // Authentication failed - oops!
  59.                 // Do something about it.
  60.             }
  61.         }
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement