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 {
15 private authService: AuthService,
16 private router: Router
19 login(username: string, password: string) {
20 this.authService.login(username, password).subscribe(
24 const user = new User(username, result);
27 this.authService.setStatus(AuthStatus.LoggedIn);
29 this.router.navigate(['VideosList']);
32 if (error.error === 'invalid_grant') {
33 this.error = 'Credentials are invalid.';
35 this.error = `${error.error}: ${error.error_description}`;