From 2028ece759357cb6f3771f8de34862258af49a58 Mon Sep 17 00:00:00 2001 From: Art Date: Fri, 17 Sep 2021 20:30:16 +0300 Subject: [PATCH] 140. Login component - grab token (#18) --- .../src/app/component/login/login.component.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/support-portal-frontend/src/app/component/login/login.component.ts b/support-portal-frontend/src/app/component/login/login.component.ts index 7497669..6c171c9 100644 --- a/support-portal-frontend/src/app/component/login/login.component.ts +++ b/support-portal-frontend/src/app/component/login/login.component.ts @@ -3,6 +3,9 @@ import {Router} from "@angular/router"; import {AuthenticationService} from "../../service/authentication.service"; import {NotificationService} from "../../service/notification.service"; import {NotificationType} from "../../notification/notification-type"; +import {Subscription} from "rxjs"; +import {UserLogin} from "../../dto/user-login"; +import {HttpErrorResponse, HttpResponse} from "@angular/common/http"; @Component({ selector: 'app-login', @@ -11,6 +14,9 @@ import {NotificationType} from "../../notification/notification-type"; }) export class LoginComponent implements OnInit, OnDestroy { + public showLoading: boolean; + private subscriptions: Subscription[] = []; + constructor(private router: Router, private authenticationService: AuthenticationService, private notificationService: NotificationService) { @@ -25,6 +31,18 @@ export class LoginComponent implements OnInit, OnDestroy { } } + public onLogin(userLogin: UserLogin): void { + this.showLoading = true; + + let subscription = this.authenticationService + .login(userLogin) + .subscribe((response: HttpResponse | HttpErrorResponse) => { + const token = response.headers.get("Jwt-Token"); + }); + + this.subscriptions.push(subscription); + } + ngOnDestroy(): void { }