import { Component, OnInit } from '@angular/core'; import { NavController } from '@ionic/angular'; import { Account } from 'src/model/account.model'; import { AccountService } from '#app/services/auth/account.service'; import { LoginService } from '#app/services/login/login.service'; @Component({ selector: 'app-home', templateUrl: 'home.page.html', styleUrls: ['home.page.scss'], }) export class HomePage implements OnInit { account: Account; constructor( public navController: NavController, private accountService: AccountService, private loginService: LoginService, ) {} ngOnInit() { this.accountService.identity().then(account => { if (account === null) { this.goBackToHomePage(); } else { this.account = account; } }); } isAuthenticated() { return this.accountService.isAuthenticated(); } logout() { this.loginService.logout(); this.goBackToHomePage(); } private goBackToHomePage(): void { this.navController.navigateBack(''); } }