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 {
13 constructor(private _authService: AuthService, private _router: Router) {}
15 login(username: string, password: string) {
16 this._authService.login(username, password).subscribe(
18 const user = new User(username, result);
21 this._authService.setStatus(AuthStatus.LoggedIn);
23 this._router.navigate(['VideosList']);
26 if (error.error === 'invalid_grant') {
27 alert('Credentials are invalid.');
29 alert(`${error.error}: ${error.error_description}`);