139. Login component - test if user is logged in already (#18)

This commit is contained in:
Art
2021-09-17 19:39:16 +03:00
parent d447189705
commit f32e9c6dc9

View File

@ -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 {
}
}