Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // LoginViewController.swift
- // AeroBuddy
- //
- // Created by Luke Collister on 28/09/2019.
- // Copyright © 2019 Luke Collister. All rights reserved.
- //
- import UIKit
- class LoginViewController: UIViewController {
- @IBOutlet var email_input: UITextField!
- @IBOutlet var password_input: UITextField!
- //let navigationController = UINavigationController()
- // Make method in viewDidLoad to check if the current credentials are set, if so login without having to press the button
- override func viewDidLoad() {
- super.viewDidLoad()
- if (ServHandler.shared.isLoggedIn()) {
- // User is logged in so segue to AC VC
- DispatchQueue.main.async {
- self.present(ServHandler.shared.acVC, animated: true, completion: nil)
- }
- }
- else {
- // Authentication failed - oops!
- // Do something about it.
- print("B")
- }
- }
- @IBAction func login(_ sender: UIButton) {
- ServHandler.shared.checkCredentials(password: password_input!.text!, for: email_input!.text!){ (result: Bool) -> Void in
- if (result) {
- DispatchQueue.main.async {
- self.present(ServHandler.shared.acVC, animated: true, completion: nil)
- }
- }
- else {
- // Authentication failed - oops!
- // Do something about it.
- }
- }
- }
- @IBAction func guestLogin(_ sender: Any) {
- ServHandler.shared.checkCredentials(password: "password", for: "ksc@ksc.me"){ (result: Bool) -> Void in
- if (result) {
- DispatchQueue.main.async {
- self.present(ServHandler.shared.acVC, animated: true, completion: nil)
- }
- }
- else {
- // Authentication failed - oops!
- // Do something about it.
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement