140. Login component - grab token (#18)
This commit is contained in:
@ -3,6 +3,9 @@ import {Router} from "@angular/router";
|
|||||||
import {AuthenticationService} from "../../service/authentication.service";
|
import {AuthenticationService} from "../../service/authentication.service";
|
||||||
import {NotificationService} from "../../service/notification.service";
|
import {NotificationService} from "../../service/notification.service";
|
||||||
import {NotificationType} from "../../notification/notification-type";
|
import {NotificationType} from "../../notification/notification-type";
|
||||||
|
import {Subscription} from "rxjs";
|
||||||
|
import {UserLogin} from "../../dto/user-login";
|
||||||
|
import {HttpErrorResponse, HttpResponse} from "@angular/common/http";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-login',
|
selector: 'app-login',
|
||||||
@ -11,6 +14,9 @@ import {NotificationType} from "../../notification/notification-type";
|
|||||||
})
|
})
|
||||||
export class LoginComponent implements OnInit, OnDestroy {
|
export class LoginComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
|
public showLoading: boolean;
|
||||||
|
private subscriptions: Subscription[] = [];
|
||||||
|
|
||||||
constructor(private router: Router,
|
constructor(private router: Router,
|
||||||
private authenticationService: AuthenticationService,
|
private authenticationService: AuthenticationService,
|
||||||
private notificationService: NotificationService) {
|
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 {
|
ngOnDestroy(): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user