I'm having difficulty with setting up a button that will take the user to another View Controller if the Firebase authentication is valid and the user and password match
@IBAction func loginButton(_ sender: Any) {
if let email:String = Username.text, let pass:String = Password.text {
FIRAuth.auth()?.signIn(withEmail: email, password: pass) { (user, error) in
if let error = error {
let errCode = FIRAuthErrorCode(rawValue: (error._code));
if (errCode == .errorCodeUserNotFound) {
self.label.text = "Error: user not found";
}
else if (errCode == .errorCodeWrongPassword) {
self.label.text = "Error: wrong password";
}
else if (errCode == .errorCodeUserDisabled) {
self.label.text = "Error: User account disabled";
}
else {
self.label.text = error.localizedDescription;
}
}
if let user = user {
self.label.text = "Signed in as " + user.email!;
self.Username.text = nil;
self.Password.text = nil;
}