aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/app/users/login/login.component.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-05-27 16:23:10 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-05-27 16:23:10 +0200
commit41a2aee38cf812510010da09de9bae53590ec119 (patch)
tree79d55d6ae0ef6f66ccb88890cf1ef1946dc65fb4 /client/app/users/login/login.component.ts
parent157cb9c9713e08ff70078660a32dd77ecb87eabc (diff)
downloadPeerTube-41a2aee38cf812510010da09de9bae53590ec119.tar.gz
PeerTube-41a2aee38cf812510010da09de9bae53590ec119.tar.zst
PeerTube-41a2aee38cf812510010da09de9bae53590ec119.zip
Follow the angular styleguide for the directories structure
Diffstat (limited to 'client/app/users/login/login.component.ts')
-rw-r--r--client/app/users/login/login.component.ts34
1 files changed, 34 insertions, 0 deletions
diff --git a/client/app/users/login/login.component.ts b/client/app/users/login/login.component.ts
new file mode 100644
index 000000000..33590ad4c
--- /dev/null
+++ b/client/app/users/login/login.component.ts
@@ -0,0 +1,34 @@
1import { Component } from '@angular/core';
2import { Router } from '@angular/router-deprecated';
3
4import { AuthService, AuthStatus, User } from '../shared/index';
5
6@Component({
7 selector: 'my-user-login',
8 styleUrls: [ 'client/app/users/login/login.component.css' ],
9 templateUrl: 'client/app/users/login/login.component.html'
10})
11
12export class UserLoginComponent {
13 constructor(private _authService: AuthService, private _router: Router) {}
14
15 login(username: string, password: string) {
16 this._authService.login(username, password).subscribe(
17 result => {
18 const user = new User(username, result);
19 user.save();
20
21 this._authService.setStatus(AuthStatus.LoggedIn);
22
23 this._router.navigate(['VideosList']);
24 },
25 error => {
26 if (error.error === 'invalid_grant') {
27 alert('Credentials are invalid.');
28 } else {
29 alert(`${error.error}: ${error.error_description}`);
30 }
31 }
32 );
33 }
34}