From c07d5a0084d1e92b4467803a0e90463d98f4e47f Mon Sep 17 00:00:00 2001 From: Matias Espinoza Date: Sat, 8 Dec 2018 12:59:42 -0300 Subject: [PATCH] Si existe una sesion dentro de la app no permite ir al login o al register --- src/app/pages/home/home.component.ts | 1 - src/app/register/login.component.ts | 2 ++ src/app/register/register.component.ts | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/app/pages/home/home.component.ts b/src/app/pages/home/home.component.ts index 0f6cbde..efe0b3e 100644 --- a/src/app/pages/home/home.component.ts +++ b/src/app/pages/home/home.component.ts @@ -17,7 +17,6 @@ export class HomeComponent implements OnInit { constructor( private _dbService:DatabaseService, private route:Router ) { const UID = JSON.parse(localStorage.getItem('user')).uid; - console.log(UID); this._dbService.getDataQuery('books', 'status', '==', 'available') .valueChanges() diff --git a/src/app/register/login.component.ts b/src/app/register/login.component.ts index bd85c33..ad250e8 100644 --- a/src/app/register/login.component.ts +++ b/src/app/register/login.component.ts @@ -31,6 +31,8 @@ export class LoginComponent implements OnInit { private router:Router, private _db:DatabaseService ) { + if( JSON.parse(localStorage.getItem('session')).session ) router.navigate(['/']); + this.afAuth.authState.subscribe( user => { console.log( 'Estado del usuario', user ); if( !user ){ diff --git a/src/app/register/register.component.ts b/src/app/register/register.component.ts index f848bc5..084463a 100644 --- a/src/app/register/register.component.ts +++ b/src/app/register/register.component.ts @@ -40,7 +40,9 @@ export class RegisterComponent implements OnInit { constructor( private _dbService:DatabaseService, private _dateService:DateService, private afAuth: AngularFireAuth, - public router: Router ) { } + public router: Router ) { + if( JSON.parse(localStorage.getItem('session')).session ) router.navigate(['/']); + } ngOnInit() { init_plugins();