mirror of
https://github.com/bpatrik/pigallery2.git
synced 2024-12-14 11:23:17 +02:00
35 lines
903 B
TypeScript
35 lines
903 B
TypeScript
import {Component, OnInit} from "@angular/core";
|
|
import {AuthenticationService} from "./model/network/authentication.service";
|
|
import {UserDTO} from "../../common/entities/UserDTO";
|
|
import {Router} from "@angular/router";
|
|
|
|
@Component({
|
|
selector: 'pi-gallery2-app',
|
|
template: `<router-outlet></router-outlet>`,
|
|
|
|
})
|
|
export class AppComponent implements OnInit {
|
|
|
|
constructor(private _router: Router, private _authenticationService: AuthenticationService) {
|
|
}
|
|
|
|
ngOnInit() {
|
|
this._authenticationService.OnUserChanged.on((user: UserDTO) => {
|
|
if (user != null) {
|
|
if (this._router.isActive('login', true)) {
|
|
console.log("routing");
|
|
this._router.navigate(["gallery", ""]);
|
|
}
|
|
} else {
|
|
if (this._router.isActive('login', true)) {
|
|
console.log("routing");
|
|
this._router.navigate(["login"]);
|
|
}
|
|
}
|
|
|
|
});
|
|
|
|
|
|
}
|
|
}
|