]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/app/users/login/login.component.ts
Do not prefix private attributes
[github/Chocobozzz/PeerTube.git] / client / app / users / 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({
7 selector: 'my-user-login',
41a2aee3
C
8 styleUrls: [ 'client/app/users/login/login.component.css' ],
9 templateUrl: 'client/app/users/login/login.component.html'
b1794c53
C
10})
11
12export class UserLoginComponent {
ccf6ed16 13 constructor(private authService: AuthService, private router: Router) {}
b1794c53
C
14
15 login(username: string, password: string) {
ccf6ed16 16 this.authService.login(username, password).subscribe(
b1794c53 17 result => {
1553e15d
C
18 const user = new User(username, result);
19 user.save();
b1794c53 20
ccf6ed16 21 this.authService.setStatus(AuthStatus.LoggedIn);
b1794c53 22
ccf6ed16 23 this.router.navigate(['VideosList']);
b1794c53 24 },
1553e15d
C
25 error => {
26 if (error.error === 'invalid_grant') {
27 alert('Credentials are invalid.');
2e2bef6f
C
28 } else {
29 alert(`${error.error}: ${error.error_description}`);
1553e15d
C
30 }
31 }
b1794c53
C
32 );
33 }
34}