140. Login component - grab token (#18)

This commit is contained in:
Art
2021-09-17 20:30:16 +03:00
parent f32e9c6dc9
commit 2028ece759

View File

@ -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<any> | HttpErrorResponse) => {
const token = response.headers.get("Jwt-Token");
});
this.subscriptions.push(subscription);
}
ngOnDestroy(): void {
}