diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-06-01 20:36:27 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-06-01 20:36:27 +0200 |
commit | a840d396093ef968f9512862197ac166a1ff9921 (patch) | |
tree | f7e4c93ee3ae8a44bd14fd1f7c74234eef7469ef /client/app/login | |
parent | 575fdcece562b914149f89f5a5b96ab206648f09 (diff) | |
download | PeerTube-a840d396093ef968f9512862197ac166a1ff9921.tar.gz PeerTube-a840d396093ef968f9512862197ac166a1ff9921.tar.zst PeerTube-a840d396093ef968f9512862197ac166a1ff9921.zip |
Add authentication tokens to make friends/quit friends
Diffstat (limited to 'client/app/login')
-rw-r--r-- | client/app/login/index.ts | 1 | ||||
-rw-r--r-- | client/app/login/login.component.html | 14 | ||||
-rw-r--r-- | client/app/login/login.component.ts | 36 |
3 files changed, 51 insertions, 0 deletions
diff --git a/client/app/login/index.ts b/client/app/login/index.ts new file mode 100644 index 000000000..69c16441f --- /dev/null +++ b/client/app/login/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './login.component'; | |||
diff --git a/client/app/login/login.component.html b/client/app/login/login.component.html new file mode 100644 index 000000000..940694515 --- /dev/null +++ b/client/app/login/login.component.html | |||
@@ -0,0 +1,14 @@ | |||
1 | <h3>Login</h3> | ||
2 | <form role="form" (submit)="login(username.value, password.value)"> | ||
3 | <div class="form-group"> | ||
4 | <label for="username">Username</label> | ||
5 | <input type="text" #username class="form-control" id="username" placeholder="Username"> | ||
6 | </div> | ||
7 | |||
8 | <div class="form-group"> | ||
9 | <label for="password">Password</label> | ||
10 | <input type="password" #password class="form-control" id="password" placeholder="Password"> | ||
11 | </div> | ||
12 | |||
13 | <input type="submit" value="Login" class="btn btn-default"> | ||
14 | </form> | ||
diff --git a/client/app/login/login.component.ts b/client/app/login/login.component.ts new file mode 100644 index 000000000..50f598d92 --- /dev/null +++ b/client/app/login/login.component.ts | |||
@@ -0,0 +1,36 @@ | |||
1 | import { Component } from '@angular/core'; | ||
2 | import { Router } from '@angular/router-deprecated'; | ||
3 | |||
4 | import { AuthService, AuthStatus, User } from '../shared/index'; | ||
5 | |||
6 | @Component({ | ||
7 | selector: 'my-login', | ||
8 | templateUrl: 'client/app/login/login.component.html' | ||
9 | }) | ||
10 | |||
11 | export class LoginComponent { | ||
12 | constructor( | ||
13 | private authService: AuthService, | ||
14 | private router: Router | ||
15 | ) {} | ||
16 | |||
17 | login(username: string, password: string) { | ||
18 | this.authService.login(username, password).subscribe( | ||
19 | result => { | ||
20 | const user = new User(username, result); | ||
21 | user.save(); | ||
22 | |||
23 | this.authService.setStatus(AuthStatus.LoggedIn); | ||
24 | |||
25 | this.router.navigate(['VideosList']); | ||
26 | }, | ||
27 | error => { | ||
28 | if (error.error === 'invalid_grant') { | ||
29 | alert('Credentials are invalid.'); | ||
30 | } else { | ||
31 | alert(`${error.error}: ${error.error_description}`); | ||
32 | } | ||
33 | } | ||
34 | ); | ||
35 | } | ||
36 | } | ||