Login page redirect

This commit is contained in:
Zakary Timson 2018-11-14 14:46:40 -05:00
parent 5d58979d6e
commit 2e498f529a

View File

@ -1,4 +1,4 @@
import {Component, OnInit} from '@angular/core';
import {Component, NgZone, OnInit} from '@angular/core';
import {environment} from '../../environments/environment';
import {firebaseApp} from '../app.module';
import {Router} from '@angular/router';
@ -11,9 +11,13 @@ import * as firebase from 'firebase';
export class LoginComponent implements OnInit {
environment = environment;
constructor(private router: Router) { }
constructor(private router: Router, private ngZone: NgZone) { }
ngOnInit() { }
ngOnInit() {
firebaseApp.auth().onAuthStateChanged(user => {
if(!!user) let ignore = this.ngZone.run(() => this.router.navigate(['/dashboard']));
})
}
async login() {
await firebase.auth().setPersistence(firebase.auth.Auth.Persistence.LOCAL);