56 lines
1.6 KiB
Swift
56 lines
1.6 KiB
Swift
//
|
|
// LoginViewController.swift
|
|
// Firebase test
|
|
//
|
|
// Created by Max Hunt on 06/05/2020.
|
|
// Copyright © 2020 smt. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
import FirebaseAuth
|
|
|
|
class LoginViewController: UIViewController {
|
|
|
|
@IBOutlet weak var email: UITextField!
|
|
@IBOutlet weak var pwd: UITextField!
|
|
@IBOutlet weak var logInBtn: UIButton!
|
|
@IBOutlet weak var errLbl: UILabel!
|
|
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
|
|
errLbl.isHidden = true
|
|
}
|
|
|
|
|
|
/*
|
|
// MARK: - Navigation
|
|
|
|
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
|
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
|
// Get the new view controller using segue.destination.
|
|
// Pass the selected object to the new view controller.
|
|
}
|
|
*/
|
|
|
|
@IBAction func loginTapped(_ sender: Any) {
|
|
self.email.text = "superuser21@averylongdomain.com"
|
|
self.pwd.text = "123456"
|
|
Auth.auth().signIn(withEmail: self.email.text!, password: self.pwd.text!) { (result, err) in
|
|
if err != nil {
|
|
self.errLbl.isHidden = false
|
|
self.errLbl.text = err?.localizedDescription
|
|
}
|
|
else {
|
|
DispatchQueue.main.async {
|
|
let HomeViewController = self.storyboard?.instantiateViewController(identifier: Constants.Storyboard.homeViewController) as? HomeViewController
|
|
self.view.window?.rootViewController = HomeViewController
|
|
self.view.window?.makeKeyAndVisible()
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|