aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-02-18 09:29:59 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-02-18 09:29:59 +0100
commitad4a8a1cca1049f600ebcdce9260c1021cd821a5 (patch)
treeca8ffba899b024d56d1bd7846f61aecae0821c82 /client/src/app
parent5d67f289df4a68e35ad7e0af3c601c7db0dc7586 (diff)
downloadPeerTube-ad4a8a1cca1049f600ebcdce9260c1021cd821a5.tar.gz
PeerTube-ad4a8a1cca1049f600ebcdce9260c1021cd821a5.tar.zst
PeerTube-ad4a8a1cca1049f600ebcdce9260c1021cd821a5.zip
Add email to users
Diffstat (limited to 'client/src/app')
-rw-r--r--client/src/app/+admin/users/shared/user.service.ts3
-rw-r--r--client/src/app/+admin/users/user-add/user-add.component.html11
-rw-r--r--client/src/app/+admin/users/user-add/user-add.component.ts14
-rw-r--r--client/src/app/+admin/users/user-list/user-list.component.ts3
-rw-r--r--client/src/app/app.component.html2
-rw-r--r--client/src/app/shared/forms/form-validators/email.validator.ts13
-rw-r--r--client/src/app/shared/forms/form-validators/host.validator.ts2
-rw-r--r--client/src/app/shared/forms/form-validators/index.ts1
-rw-r--r--client/src/app/shared/forms/form-validators/user.ts9
9 files changed, 52 insertions, 6 deletions
diff --git a/client/src/app/+admin/users/shared/user.service.ts b/client/src/app/+admin/users/shared/user.service.ts
index f6d360e09..a92f9c231 100644
--- a/client/src/app/+admin/users/shared/user.service.ts
+++ b/client/src/app/+admin/users/shared/user.service.ts
@@ -14,9 +14,10 @@ export class UserService {
14 private restExtractor: RestExtractor 14 private restExtractor: RestExtractor
15 ) {} 15 ) {}
16 16
17 addUser(username: string, password: string) { 17 addUser(username: string, password: string, email: string) {
18 const body = { 18 const body = {
19 username, 19 username,
20 email,
20 password 21 password
21 }; 22 };
22 23
diff --git a/client/src/app/+admin/users/user-add/user-add.component.html b/client/src/app/+admin/users/user-add/user-add.component.html
index 9b76c7c1b..105760f48 100644
--- a/client/src/app/+admin/users/user-add/user-add.component.html
+++ b/client/src/app/+admin/users/user-add/user-add.component.html
@@ -15,6 +15,17 @@
15 </div> 15 </div>
16 16
17 <div class="form-group"> 17 <div class="form-group">
18 <label for="email">Email</label>
19 <input
20 type="text" class="form-control" id="email" placeholder="Email"
21 formControlName="email"
22 >
23 <div *ngIf="formErrors.email" class="alert alert-danger">
24 {{ formErrors.email }}
25 </div>
26 </div>
27
28 <div class="form-group">
18 <label for="password">Password</label> 29 <label for="password">Password</label>
19 <input 30 <input
20 type="password" class="form-control" id="password" placeholder="Password" 31 type="password" class="form-control" id="password" placeholder="Password"
diff --git a/client/src/app/+admin/users/user-add/user-add.component.ts b/client/src/app/+admin/users/user-add/user-add.component.ts
index a851fee44..f1d2fde80 100644
--- a/client/src/app/+admin/users/user-add/user-add.component.ts
+++ b/client/src/app/+admin/users/user-add/user-add.component.ts
@@ -5,7 +5,12 @@ import { Router } from '@angular/router';
5import { NotificationsService } from 'angular2-notifications'; 5import { NotificationsService } from 'angular2-notifications';
6 6
7import { UserService } from '../shared'; 7import { UserService } from '../shared';
8import { FormReactive, USER_USERNAME, USER_PASSWORD } from '../../../shared'; 8import {
9 FormReactive,
10 USER_USERNAME,
11 USER_EMAIL,
12 USER_PASSWORD
13} from '../../../shared';
9 14
10@Component({ 15@Component({
11 selector: 'my-user-add', 16 selector: 'my-user-add',
@@ -17,10 +22,12 @@ export class UserAddComponent extends FormReactive implements OnInit {
17 form: FormGroup; 22 form: FormGroup;
18 formErrors = { 23 formErrors = {
19 'username': '', 24 'username': '',
25 'email': '',
20 'password': '' 26 'password': ''
21 }; 27 };
22 validationMessages = { 28 validationMessages = {
23 'username': USER_USERNAME.MESSAGES, 29 'username': USER_USERNAME.MESSAGES,
30 'email': USER_EMAIL.MESSAGES,
24 'password': USER_PASSWORD.MESSAGES, 31 'password': USER_PASSWORD.MESSAGES,
25 }; 32 };
26 33
@@ -36,6 +43,7 @@ export class UserAddComponent extends FormReactive implements OnInit {
36 buildForm() { 43 buildForm() {
37 this.form = this.formBuilder.group({ 44 this.form = this.formBuilder.group({
38 username: [ '', USER_USERNAME.VALIDATORS ], 45 username: [ '', USER_USERNAME.VALIDATORS ],
46 email: [ '', USER_EMAIL.VALIDATORS ],
39 password: [ '', USER_PASSWORD.VALIDATORS ], 47 password: [ '', USER_PASSWORD.VALIDATORS ],
40 }); 48 });
41 49
@@ -49,9 +57,9 @@ export class UserAddComponent extends FormReactive implements OnInit {
49 addUser() { 57 addUser() {
50 this.error = null; 58 this.error = null;
51 59
52 const { username, password } = this.form.value; 60 const { username, password, email } = this.form.value;
53 61
54 this.userService.addUser(username, password).subscribe( 62 this.userService.addUser(username, password, email).subscribe(
55 () => { 63 () => {
56 this.notificationsService.success('Success', `User ${username} created.`); 64 this.notificationsService.success('Success', `User ${username} created.`);
57 this.router.navigate([ '/admin/users/list' ]); 65 this.router.navigate([ '/admin/users/list' ]);
diff --git a/client/src/app/+admin/users/user-list/user-list.component.ts b/client/src/app/+admin/users/user-list/user-list.component.ts
index c27b96e28..69ae4353d 100644
--- a/client/src/app/+admin/users/user-list/user-list.component.ts
+++ b/client/src/app/+admin/users/user-list/user-list.component.ts
@@ -40,6 +40,9 @@ export class UserListComponent {
40 username: { 40 username: {
41 title: 'Username' 41 title: 'Username'
42 }, 42 },
43 email: {
44 title: 'Email'
45 },
43 role: { 46 role: {
44 title: 'Role', 47 title: 'Role',
45 sort: false 48 sort: false
diff --git a/client/src/app/app.component.html b/client/src/app/app.component.html
index 9f2661e12..0c8e18a2f 100644
--- a/client/src/app/app.component.html
+++ b/client/src/app/app.component.html
@@ -26,6 +26,6 @@
26 <my-confirm></my-confirm> 26 <my-confirm></my-confirm>
27 27
28 <footer> 28 <footer>
29 PeerTube, CopyLeft 2015-2016 29 PeerTube, CopyLeft 2015-2017
30 </footer> 30 </footer>
31</div> 31</div>
diff --git a/client/src/app/shared/forms/form-validators/email.validator.ts b/client/src/app/shared/forms/form-validators/email.validator.ts
new file mode 100644
index 000000000..6a2c3bdca
--- /dev/null
+++ b/client/src/app/shared/forms/form-validators/email.validator.ts
@@ -0,0 +1,13 @@
1import { FormControl } from '@angular/forms';
2
3export function validateEmail(c: FormControl) {
4 // Thanks to http://emailregex.com/
5 /* tslint:disable */
6 const EMAIL_REGEXP = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
7
8 return EMAIL_REGEXP.test(c.value) ? null : {
9 email: {
10 valid: false
11 }
12 };
13}
diff --git a/client/src/app/shared/forms/form-validators/host.validator.ts b/client/src/app/shared/forms/form-validators/host.validator.ts
index ea3e43cb1..ec417e079 100644
--- a/client/src/app/shared/forms/form-validators/host.validator.ts
+++ b/client/src/app/shared/forms/form-validators/host.validator.ts
@@ -2,7 +2,7 @@ import { FormControl } from '@angular/forms';
2 2
3export function validateHost(c: FormControl) { 3export function validateHost(c: FormControl) {
4 // Thanks to http://stackoverflow.com/a/106223 4 // Thanks to http://stackoverflow.com/a/106223
5 let HOST_REGEXP = new RegExp( 5 const HOST_REGEXP = new RegExp(
6 '^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$' 6 '^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$'
7 ); 7 );
8 8
diff --git a/client/src/app/shared/forms/form-validators/index.ts b/client/src/app/shared/forms/form-validators/index.ts
index ab7c2df31..669411a54 100644
--- a/client/src/app/shared/forms/form-validators/index.ts
+++ b/client/src/app/shared/forms/form-validators/index.ts
@@ -1,3 +1,4 @@
1export * from './email.validator';
1export * from './host.validator'; 2export * from './host.validator';
2export * from './user'; 3export * from './user';
3export * from './video-abuse'; 4export * from './video-abuse';
diff --git a/client/src/app/shared/forms/form-validators/user.ts b/client/src/app/shared/forms/form-validators/user.ts
index 5b11ff265..0ad0e2a4b 100644
--- a/client/src/app/shared/forms/form-validators/user.ts
+++ b/client/src/app/shared/forms/form-validators/user.ts
@@ -1,5 +1,7 @@
1import { Validators } from '@angular/forms'; 1import { Validators } from '@angular/forms';
2 2
3import { validateEmail } from './email.validator';
4
3export const USER_USERNAME = { 5export const USER_USERNAME = {
4 VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(20) ], 6 VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(20) ],
5 MESSAGES: { 7 MESSAGES: {
@@ -8,6 +10,13 @@ export const USER_USERNAME = {
8 'maxlength': 'Username cannot be more than 20 characters long.' 10 'maxlength': 'Username cannot be more than 20 characters long.'
9 } 11 }
10}; 12};
13export const USER_EMAIL = {
14 VALIDATORS: [ Validators.required, validateEmail ],
15 MESSAGES: {
16 'required': 'Email is required.',
17 'email': 'Email must be valid.',
18 }
19};
11export const USER_PASSWORD = { 20export const USER_PASSWORD = {
12 VALIDATORS: [ Validators.required, Validators.minLength(6) ], 21 VALIDATORS: [ Validators.required, Validators.minLength(6) ],
13 MESSAGES: { 22 MESSAGES: {