2020-11-11 18:24:02 +00:00
|
|
|
import {Component, OnInit} from '@angular/core';
|
2020-02-08 04:19:35 +00:00
|
|
|
import {ApiService} from '../service/api.service';
|
2020-11-11 18:24:02 +00:00
|
|
|
import {isDebug, debug} from '../utility';
|
2021-03-04 17:26:39 +00:00
|
|
|
import {Router} from '@angular/router';
|
2020-02-08 02:01:00 +00:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-home',
|
|
|
|
templateUrl: 'home.page.html',
|
|
|
|
styleUrls: ['home.page.scss'],
|
|
|
|
})
|
2020-11-11 18:24:02 +00:00
|
|
|
export class HomePage implements OnInit {
|
2020-02-08 04:19:35 +00:00
|
|
|
constructor(
|
2020-11-11 18:24:02 +00:00
|
|
|
public readonly api: ApiService,
|
2021-03-04 17:26:39 +00:00
|
|
|
public readonly router: Router,
|
2020-02-08 04:19:35 +00:00
|
|
|
) {}
|
2020-02-08 02:01:00 +00:00
|
|
|
|
2020-11-11 18:24:02 +00:00
|
|
|
ngOnInit() {
|
|
|
|
if ( !this.api.isAuthenticated || this.api.isPublicUser ) {
|
|
|
|
if ( isDebug() ) {
|
|
|
|
debug('Forcing authentication...');
|
|
|
|
setTimeout(() => {
|
2021-03-04 17:26:39 +00:00
|
|
|
this.router.navigate(['/login']);
|
2020-11-11 18:24:02 +00:00
|
|
|
}, 2000);
|
|
|
|
} else {
|
2021-03-04 17:26:39 +00:00
|
|
|
this.router.navigate(['/login']);
|
2020-11-11 18:24:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-02-08 02:01:00 +00:00
|
|
|
}
|