]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - client/src/app/login/login.component.ts
Client: implement password change
[github/Chocobozzz/PeerTube.git] / client / src / app / login / login.component.ts
... / ...
CommitLineData
1import { Component } from '@angular/core';
2import { Router } from '@angular/router';
3
4import { AuthService } from '../shared';
5
6@Component({
7 selector: 'my-login',
8 template: require('./login.component.html')
9})
10
11export class LoginComponent {
12 error: string = null;
13
14 constructor(
15 private authService: AuthService,
16 private router: Router
17 ) {}
18
19 login(username: string, password: string) {
20 this.authService.login(username, password).subscribe(
21 result => {
22 this.error = null;
23
24 this.router.navigate(['/videos/list']);
25 },
26 error => {
27 console.error(error);
28
29 if (error.error === 'invalid_grant') {
30 this.error = 'Credentials are invalid.';
31 } else {
32 this.error = `${error.error}: ${error.error_description}`;
33 }
34 }
35 );
36 }
37}