1 import { Component } from '@angular/core';
2 import { Router } from '@angular/router-deprecated';
4 import { AuthService, AuthStatus, User } from '../shared';
8 template: require('./login.component.html')
11 export class LoginComponent {
13 private authService: AuthService,
14 private router: Router
17 login(username: string, password: string) {
18 this.authService.login(username, password).subscribe(
20 const user = new User(username, result);
23 this.authService.setStatus(AuthStatus.LoggedIn);
25 this.router.navigate(['VideosList']);
28 if (error.error === 'invalid_grant') {
29 alert('Credentials are invalid.');
31 alert(`${error.error}: ${error.error_description}`);