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