]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/app/login/login.component.ts
Add systemd file example
[github/Chocobozzz/PeerTube.git] / client / app / login / login.component.ts
CommitLineData
230809ef
C
1import { Component } from '@angular/core';
2import { Router } from '@angular/router-deprecated';
b1794c53 3
41a2aee3 4import { AuthService, AuthStatus, User } from '../shared/index';
b1794c53
C
5
6@Component({
a840d396
C
7 selector: 'my-login',
8 templateUrl: 'client/app/login/login.component.html'
b1794c53
C
9})
10
a840d396 11export class LoginComponent {
4fd8aa32
C
12 constructor(
13 private authService: AuthService,
14 private router: Router
15 ) {}
b1794c53
C
16
17 login(username: string, password: string) {
ccf6ed16 18 this.authService.login(username, password).subscribe(
b1794c53 19 result => {
1553e15d
C
20 const user = new User(username, result);
21 user.save();
b1794c53 22
ccf6ed16 23 this.authService.setStatus(AuthStatus.LoggedIn);
b1794c53 24
ccf6ed16 25 this.router.navigate(['VideosList']);
b1794c53 26 },
1553e15d
C
27 error => {
28 if (error.error === 'invalid_grant') {
29 alert('Credentials are invalid.');
2e2bef6f
C
30 } else {
31 alert(`${error.error}: ${error.error_description}`);
1553e15d
C
32 }
33 }
b1794c53
C
34 );
35 }
36}