From 23b14a4d6197f75685f3d8257bee964bb7379473 Mon Sep 17 00:00:00 2001 From: Lukas Kimpel <lukas.kimpel@mni.thm.de> Date: Tue, 6 Mar 2018 15:48:11 +0100 Subject: [PATCH] Add usage of AuthenticationService and NotificationService --- src/app/login/login.component.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/app/login/login.component.ts b/src/app/login/login.component.ts index 23b4fc0ca..89883adf2 100644 --- a/src/app/login/login.component.ts +++ b/src/app/login/login.component.ts @@ -1,4 +1,7 @@ import { Component, OnInit } from '@angular/core'; +import { AuthenticationService } from '../authentication.service'; +import { Router } from '@angular/router'; +import { NotificationService } from '../notification.service'; @Component({ selector: 'app-login', @@ -7,7 +10,7 @@ import { Component, OnInit } from '@angular/core'; }) export class LoginComponent implements OnInit { - constructor() { + constructor(public authenticationService: AuthenticationService, public router: Router, public notificationService: NotificationService) { } ngOnInit() { @@ -21,7 +24,16 @@ export class LoginComponent implements OnInit { // ToDo: Handle username and password not correct event console.log(`Username or password empty`); } else { - // ToDo: Send data to authentication service + this.authenticationService.login(username, password).subscribe(loginSuccessful => { + console.log(loginSuccessful); + if (loginSuccessful) { + this.notificationService.show('Login successful!'); + this.router.navigate(['rooms']); + } else { + this.notificationService.show('Login failed!'); + this.router.navigate(['home']); + } + }); } } -- GitLab