aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/angular/users/components/login
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-03-22 15:51:54 +0100
committerChocobozzz <florian.bigard@gmail.com>2016-03-22 15:51:54 +0100
commitb1794c53ac97d77a16c10ed915336f08cff1e5e3 (patch)
tree9dd64ee8316e1e60c434a7d0a6dcbace49eb4d6b /client/angular/users/components/login
parent13ce1d01c953f0c4fd3b1d714c016f927dc16f66 (diff)
downloadPeerTube-b1794c53ac97d77a16c10ed915336f08cff1e5e3.tar.gz
PeerTube-b1794c53ac97d77a16c10ed915336f08cff1e5e3.tar.zst
PeerTube-b1794c53ac97d77a16c10ed915336f08cff1e5e3.zip
Login in Angular : first draft
Diffstat (limited to 'client/angular/users/components/login')
-rw-r--r--client/angular/users/components/login/login.component.html14
-rw-r--r--client/angular/users/components/login/login.component.scss0
-rw-r--r--client/angular/users/components/login/login.component.ts32
3 files changed, 46 insertions, 0 deletions
diff --git a/client/angular/users/components/login/login.component.html b/client/angular/users/components/login/login.component.html
new file mode 100644
index 000000000..940694515
--- /dev/null
+++ b/client/angular/users/components/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/angular/users/components/login/login.component.scss b/client/angular/users/components/login/login.component.scss
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/client/angular/users/components/login/login.component.scss
diff --git a/client/angular/users/components/login/login.component.ts b/client/angular/users/components/login/login.component.ts
new file mode 100644
index 000000000..0881a3a15
--- /dev/null
+++ b/client/angular/users/components/login/login.component.ts
@@ -0,0 +1,32 @@
1import { Component } from 'angular2/core';
2import { Router } from 'angular2/router';
3
4import { AuthService } from '../../services/auth.service';
5import { AuthStatus } from '../../models/authStatus';
6import { Token } from '../../models/token';
7
8@Component({
9 selector: 'my-user-login',
10 styleUrls: [ 'app/angular/users/components/login/login.component.css' ],
11 templateUrl: 'app/angular/users/components/login/login.component.html'
12})
13
14export class UserLoginComponent {
15 constructor(private _authService: AuthService, private _router: Router) {}
16
17 login(username: string, password: string) {
18 this._authService.login(username, password).subscribe(
19 result => {
20 if (result.error) return alert(result.error_description);
21
22 let token = new Token(result);
23 token.save();
24
25 this._authService.setStatus(AuthStatus.LoggedIn);
26
27 this._router.navigate(['VideosList']);
28 },
29 error => alert(error)
30 );
31 }
32}