aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/account/account-settings/account-change-password
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-12-01 17:38:26 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-12-01 17:38:26 +0100
commitc30745f342480b59fb0856a059c8c2fbffbcfc6a (patch)
tree06209d7831131120b097b538c0ed851f8e40a280 /client/src/app/account/account-settings/account-change-password
parent2bbb34127fccd187ed690949b6791e49fdd77194 (diff)
downloadPeerTube-c30745f342480b59fb0856a059c8c2fbffbcfc6a.tar.gz
PeerTube-c30745f342480b59fb0856a059c8c2fbffbcfc6a.tar.zst
PeerTube-c30745f342480b59fb0856a059c8c2fbffbcfc6a.zip
Add account settings new design
Diffstat (limited to 'client/src/app/account/account-settings/account-change-password')
-rw-r--r--client/src/app/account/account-settings/account-change-password/account-change-password.component.html18
-rw-r--r--client/src/app/account/account-settings/account-change-password/account-change-password.component.scss9
-rw-r--r--client/src/app/account/account-settings/account-change-password/account-change-password.component.ts62
-rw-r--r--client/src/app/account/account-settings/account-change-password/index.ts1
4 files changed, 90 insertions, 0 deletions
diff --git a/client/src/app/account/account-settings/account-change-password/account-change-password.component.html b/client/src/app/account/account-settings/account-change-password/account-change-password.component.html
new file mode 100644
index 000000000..bfb55218f
--- /dev/null
+++ b/client/src/app/account/account-settings/account-change-password/account-change-password.component.html
@@ -0,0 +1,18 @@
1<div *ngIf="error" class="alert alert-danger">{{ error }}</div>
2
3<form role="form" (ngSubmit)="changePassword()" [formGroup]="form">
4 <input
5 type="password" class="form-control" id="new-password" placeholder="Old password"
6 formControlName="new-password"
7 >
8 <div *ngIf="formErrors['new-password']" class="alert alert-danger">
9 {{ formErrors['new-password'] }}
10 </div>
11
12 <input
13 type="password" id="new-confirmed-password" placeholder="New password"
14 formControlName="new-confirmed-password"
15 >
16
17 <input type="submit" value="Change password" [disabled]="!form.valid">
18</form>
diff --git a/client/src/app/account/account-settings/account-change-password/account-change-password.component.scss b/client/src/app/account/account-settings/account-change-password/account-change-password.component.scss
new file mode 100644
index 000000000..593355b70
--- /dev/null
+++ b/client/src/app/account/account-settings/account-change-password/account-change-password.component.scss
@@ -0,0 +1,9 @@
1input[type=password] {
2 @include peertube-input-text(340px);
3 display: block;
4 margin-bottom: 10px;
5}
6
7input[type=submit] {
8 @include peertube-button;
9}
diff --git a/client/src/app/account/account-settings/account-change-password/account-change-password.component.ts b/client/src/app/account/account-settings/account-change-password/account-change-password.component.ts
new file mode 100644
index 000000000..8979e1734
--- /dev/null
+++ b/client/src/app/account/account-settings/account-change-password/account-change-password.component.ts
@@ -0,0 +1,62 @@
1import { Component, OnInit } from '@angular/core'
2import { FormBuilder, FormGroup } from '@angular/forms'
3import { NotificationsService } from 'angular2-notifications'
4import { FormReactive, USER_PASSWORD, UserService } from '../../../shared'
5
6@Component({
7 selector: 'my-account-change-password',
8 templateUrl: './account-change-password.component.html',
9 styleUrls: [ './account-change-password.component.scss' ]
10})
11export class AccountChangePasswordComponent extends FormReactive implements OnInit {
12 error: string = null
13
14 form: FormGroup
15 formErrors = {
16 'new-password': '',
17 'new-confirmed-password': ''
18 }
19 validationMessages = {
20 'new-password': USER_PASSWORD.MESSAGES,
21 'new-confirmed-password': USER_PASSWORD.MESSAGES
22 }
23
24 constructor (
25 private formBuilder: FormBuilder,
26 private notificationsService: NotificationsService,
27 private userService: UserService
28 ) {
29 super()
30 }
31
32 buildForm () {
33 this.form = this.formBuilder.group({
34 'new-password': [ '', USER_PASSWORD.VALIDATORS ],
35 'new-confirmed-password': [ '', USER_PASSWORD.VALIDATORS ]
36 })
37
38 this.form.valueChanges.subscribe(data => this.onValueChanged(data))
39 }
40
41 ngOnInit () {
42 this.buildForm()
43 }
44
45 changePassword () {
46 const newPassword = this.form.value['new-password']
47 const newConfirmedPassword = this.form.value['new-confirmed-password']
48
49 this.error = null
50
51 if (newPassword !== newConfirmedPassword) {
52 this.error = 'The new password and the confirmed password do not correspond.'
53 return
54 }
55
56 this.userService.changePassword(newPassword).subscribe(
57 () => this.notificationsService.success('Success', 'Password updated.'),
58
59 err => this.error = err.message
60 )
61 }
62}
diff --git a/client/src/app/account/account-settings/account-change-password/index.ts b/client/src/app/account/account-settings/account-change-password/index.ts
new file mode 100644
index 000000000..44c330b66
--- /dev/null
+++ b/client/src/app/account/account-settings/account-change-password/index.ts
@@ -0,0 +1 @@
export * from './account-change-password.component'