1 import { Component } from '@angular/core';
2 import { Router } from '@angular/router-deprecated';
4 import { AuthService, AuthStatus, User } from '../shared/index';
7 selector: 'my-user-login',
8 styleUrls: [ 'client/app/users/login/login.component.css' ],
9 templateUrl: 'client/app/users/login/login.component.html'
12 export class UserLoginComponent {
14 private authService: AuthService,
15 private router: Router
18 login(username: string, password: string) {
19 this.authService.login(username, password).subscribe(
21 const user = new User(username, result);
24 this.authService.setStatus(AuthStatus.LoggedIn);
26 this.router.navigate(['VideosList']);
29 if (error.error === 'invalid_grant') {
30 alert('Credentials are invalid.');
32 alert(`${error.error}: ${error.error_description}`);