1 import { Component } from '@angular/core';
2 import { Router } from '@angular/router-deprecated';
4 import { AuthService } from '../../services/auth.service';
5 import { AuthStatus } from '../../models/authStatus';
6 import { User } from '../../models/user';
9 selector: 'my-user-login',
10 styleUrls: [ 'app/angular/users/components/login/login.component.css' ],
11 templateUrl: 'app/angular/users/components/login/login.component.html'
14 export class UserLoginComponent {
15 constructor(private _authService: AuthService, 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}`);