139. Login component - test if user is logged in already (#18)
This commit is contained in:
@ -1,15 +1,31 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {Component, OnDestroy, OnInit} from '@angular/core';
|
||||
import {Router} from "@angular/router";
|
||||
import {AuthenticationService} from "../../service/authentication.service";
|
||||
import {NotificationService} from "../../service/notification.service";
|
||||
import {NotificationType} from "../../notification/notification-type";
|
||||
|
||||
@Component({
|
||||
selector: 'app-login',
|
||||
templateUrl: './login.component.html',
|
||||
styleUrls: ['./login.component.css']
|
||||
})
|
||||
export class LoginComponent implements OnInit {
|
||||
export class LoginComponent implements OnInit, OnDestroy {
|
||||
|
||||
constructor() { }
|
||||
constructor(private router: Router,
|
||||
private authenticationService: AuthenticationService,
|
||||
private notificationService: NotificationService) {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
if (this.authenticationService.isUserLoggedIn()) {
|
||||
this.router.navigateByUrl("/user/management");
|
||||
this.notificationService.notify(NotificationType.INFO, "You are already logged in");
|
||||
} else {
|
||||
// this.router.navigateByUrl("/login");
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user