1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00
pigallery2/frontend/app/app.component.ts
2016-12-26 23:36:38 +01:00

34 lines
1003 B
TypeScript

import {Component, OnInit} from "@angular/core";
import {AuthenticationService} from "./model/network/authentication.service";
import {User} from "../../common/entities/User";
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: User) => {
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"]);
}
}
});
}
}