aboutsummaryrefslogtreecommitdiffhomepage
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/src/app/+admin/users/user-list/user-list.component.html12
-rw-r--r--client/src/app/+admin/users/user-list/user-list.component.ts26
-rw-r--r--client/src/app/shared/moderation/user-moderation-dropdown.component.ts25
-rw-r--r--client/src/app/shared/users/user.model.ts2
-rw-r--r--client/src/app/shared/users/user.service.ts9
5 files changed, 71 insertions, 3 deletions
diff --git a/client/src/app/+admin/users/user-list/user-list.component.html b/client/src/app/+admin/users/user-list/user-list.component.html
index 5684004a5..556ab3c5d 100644
--- a/client/src/app/+admin/users/user-list/user-list.component.html
+++ b/client/src/app/+admin/users/user-list/user-list.component.html
@@ -65,7 +65,17 @@
65 <span i18n *ngIf="user.blocked" class="banned-info">(banned)</span> 65 <span i18n *ngIf="user.blocked" class="banned-info">(banned)</span>
66 </a> 66 </a>
67 </td> 67 </td>
68 <td>{{ user.email }}</td> 68 <td *ngIf="!requiresEmailVerification || user.blocked; else emailWithVerificationStatus">{{ user.email }}</td>
69 <ng-template #emailWithVerificationStatus>
70 <td *ngIf="user.emailVerified === false; else emailVerifiedNotFalse" i18n-title title="User's email must be verified to login">
71 <em>? {{ user.email }}</em>
72 </td>
73 <ng-template #emailVerifiedNotFalse>
74 <td i18n-title title="User's email is verified / User can login without email verification">
75 &#x2713; {{ user.email }}
76 </td>
77 </ng-template>
78 </ng-template>
69 <td>{{ user.videoQuotaUsed }} / {{ user.videoQuota }}</td> 79 <td>{{ user.videoQuotaUsed }} / {{ user.videoQuota }}</td>
70 <td>{{ user.roleLabel }}</td> 80 <td>{{ user.roleLabel }}</td>
71 <td>{{ user.createdAt }}</td> 81 <td>{{ user.createdAt }}</td>
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 31e783622..fb085c133 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
@@ -1,7 +1,7 @@
1import { Component, OnInit, ViewChild } from '@angular/core' 1import { Component, OnInit, ViewChild } from '@angular/core'
2import { NotificationsService } from 'angular2-notifications' 2import { NotificationsService } from 'angular2-notifications'
3import { SortMeta } from 'primeng/components/common/sortmeta' 3import { SortMeta } from 'primeng/components/common/sortmeta'
4import { ConfirmService } from '../../../core' 4import { ConfirmService, ServerService } from '../../../core'
5import { RestPagination, RestTable, UserService } from '../../../shared' 5import { RestPagination, RestTable, UserService } from '../../../shared'
6import { I18n } from '@ngx-translate/i18n-polyfill' 6import { I18n } from '@ngx-translate/i18n-polyfill'
7import { User } from '../../../../../../shared' 7import { User } from '../../../../../../shared'
@@ -28,12 +28,17 @@ export class UserListComponent extends RestTable implements OnInit {
28 constructor ( 28 constructor (
29 private notificationsService: NotificationsService, 29 private notificationsService: NotificationsService,
30 private confirmService: ConfirmService, 30 private confirmService: ConfirmService,
31 private serverService: ServerService,
31 private userService: UserService, 32 private userService: UserService,
32 private i18n: I18n 33 private i18n: I18n
33 ) { 34 ) {
34 super() 35 super()
35 } 36 }
36 37
38 get requiresEmailVerification () {
39 return this.serverService.getConfig().signup.requiresEmailVerification
40 }
41
37 ngOnInit () { 42 ngOnInit () {
38 this.initialize() 43 this.initialize()
39 44
@@ -51,6 +56,11 @@ export class UserListComponent extends RestTable implements OnInit {
51 label: this.i18n('Unban'), 56 label: this.i18n('Unban'),
52 handler: users => this.unbanUsers(users), 57 handler: users => this.unbanUsers(users),
53 isDisplayed: users => users.every(u => u.blocked === true) 58 isDisplayed: users => users.every(u => u.blocked === true)
59 },
60 {
61 label: this.i18n('Set Email as Verified'),
62 handler: users => this.setEmailsAsVerified(users),
63 isDisplayed: users => this.requiresEmailVerification && users.every(u => !u.blocked && u.emailVerified === false)
54 } 64 }
55 ] 65 ]
56 } 66 }
@@ -114,6 +124,20 @@ export class UserListComponent extends RestTable implements OnInit {
114 ) 124 )
115 } 125 }
116 126
127 async setEmailsAsVerified (users: User[]) {
128 this.userService.updateUsers(users, { emailVerified: true }).subscribe(
129 () => {
130 this.notificationsService.success(
131 this.i18n('Success'),
132 this.i18n('{{num}} users email set as verified.', { num: users.length })
133 )
134 this.loadData()
135 },
136
137 err => this.notificationsService.error(this.i18n('Error'), err.message)
138 )
139 }
140
117 isInSelectionMode () { 141 isInSelectionMode () {
118 return this.selectedUsers.length !== 0 142 return this.selectedUsers.length !== 0
119 } 143 }
diff --git a/client/src/app/shared/moderation/user-moderation-dropdown.component.ts b/client/src/app/shared/moderation/user-moderation-dropdown.component.ts
index 908f0b8e0..460750740 100644
--- a/client/src/app/shared/moderation/user-moderation-dropdown.component.ts
+++ b/client/src/app/shared/moderation/user-moderation-dropdown.component.ts
@@ -4,7 +4,7 @@ import { I18n } from '@ngx-translate/i18n-polyfill'
4import { DropdownAction } from '@app/shared/buttons/action-dropdown.component' 4import { DropdownAction } from '@app/shared/buttons/action-dropdown.component'
5import { UserBanModalComponent } from '@app/shared/moderation/user-ban-modal.component' 5import { UserBanModalComponent } from '@app/shared/moderation/user-ban-modal.component'
6import { UserService } from '@app/shared/users' 6import { UserService } from '@app/shared/users'
7import { AuthService, ConfirmService } from '@app/core' 7import { AuthService, ConfirmService, ServerService } from '@app/core'
8import { User, UserRight } from '../../../../../shared/models/users' 8import { User, UserRight } from '../../../../../shared/models/users'
9import { Account } from '@app/shared/account/account.model' 9import { Account } from '@app/shared/account/account.model'
10import { BlocklistService } from '@app/shared/blocklist' 10import { BlocklistService } from '@app/shared/blocklist'
@@ -32,11 +32,16 @@ export class UserModerationDropdownComponent implements OnChanges {
32 private authService: AuthService, 32 private authService: AuthService,
33 private notificationsService: NotificationsService, 33 private notificationsService: NotificationsService,
34 private confirmService: ConfirmService, 34 private confirmService: ConfirmService,
35 private serverService: ServerService,
35 private userService: UserService, 36 private userService: UserService,
36 private blocklistService: BlocklistService, 37 private blocklistService: BlocklistService,
37 private i18n: I18n 38 private i18n: I18n
38 ) { } 39 ) { }
39 40
41 get requiresEmailVerification () {
42 return this.serverService.getConfig().signup.requiresEmailVerification
43 }
44
40 ngOnChanges () { 45 ngOnChanges () {
41 this.buildActions() 46 this.buildActions()
42 } 47 }
@@ -97,6 +102,19 @@ export class UserModerationDropdownComponent implements OnChanges {
97 ) 102 )
98 } 103 }
99 104
105 setEmailAsVerified (user: User) {
106 this.userService.updateUser(user.id, { emailVerified: true }).subscribe(
107 () => {
108 this.notificationsService.success(
109 this.i18n('Success'),
110 this.i18n('User {{username}} email set as verified', { username: user.username })
111 )
112 },
113
114 err => this.notificationsService.error(this.i18n('Error'), err.message)
115 )
116 }
117
100 blockAccountByUser (account: Account) { 118 blockAccountByUser (account: Account) {
101 this.blocklistService.blockAccountByUser(account) 119 this.blocklistService.blockAccountByUser(account)
102 .subscribe( 120 .subscribe(
@@ -264,6 +282,11 @@ export class UserModerationDropdownComponent implements OnChanges {
264 label: this.i18n('Unban'), 282 label: this.i18n('Unban'),
265 handler: ({ user }: { user: User }) => this.unbanUser(user), 283 handler: ({ user }: { user: User }) => this.unbanUser(user),
266 isDisplayed: ({ user }: { user: User }) => user.blocked 284 isDisplayed: ({ user }: { user: User }) => user.blocked
285 },
286 {
287 label: this.i18n('Set Email as Verified'),
288 handler: ({ user }: { user: User }) => this.setEmailAsVerified(user),
289 isDisplayed: ({ user }: { user: User }) => this.requiresEmailVerification && !user.blocked && user.emailVerified === false
267 } 290 }
268 ]) 291 ])
269 } 292 }
diff --git a/client/src/app/shared/users/user.model.ts b/client/src/app/shared/users/user.model.ts
index 7c840ffa7..9819829fd 100644
--- a/client/src/app/shared/users/user.model.ts
+++ b/client/src/app/shared/users/user.model.ts
@@ -15,6 +15,7 @@ export type UserConstructorHash = {
15 username: string, 15 username: string,
16 email: string, 16 email: string,
17 role: UserRole, 17 role: UserRole,
18 emailVerified?: boolean,
18 videoQuota?: number, 19 videoQuota?: number,
19 videoQuotaDaily?: number, 20 videoQuotaDaily?: number,
20 nsfwPolicy?: NSFWPolicyType, 21 nsfwPolicy?: NSFWPolicyType,
@@ -31,6 +32,7 @@ export class User implements UserServerModel {
31 id: number 32 id: number
32 username: string 33 username: string
33 email: string 34 email: string
35 emailVerified: boolean
34 role: UserRole 36 role: UserRole
35 nsfwPolicy: NSFWPolicyType 37 nsfwPolicy: NSFWPolicyType
36 webTorrentEnabled: boolean 38 webTorrentEnabled: boolean
diff --git a/client/src/app/shared/users/user.service.ts b/client/src/app/shared/users/user.service.ts
index 27a81f0a2..cc5c051f1 100644
--- a/client/src/app/shared/users/user.service.ts
+++ b/client/src/app/shared/users/user.service.ts
@@ -153,6 +153,15 @@ export class UserService {
153 ) 153 )
154 } 154 }
155 155
156 updateUsers (users: User[], userUpdate: UserUpdate) {
157 return from(users)
158 .pipe(
159 concatMap(u => this.authHttp.put(UserService.BASE_USERS_URL + u.id, userUpdate)),
160 toArray(),
161 catchError(err => this.restExtractor.handleError(err))
162 )
163 }
164
156 getUser (userId: number) { 165 getUser (userId: number) {
157 return this.authHttp.get<User>(UserService.BASE_USERS_URL + userId) 166 return this.authHttp.get<User>(UserService.BASE_USERS_URL + userId)
158 .pipe(catchError(err => this.restExtractor.handleError(err))) 167 .pipe(catchError(err => this.restExtractor.handleError(err)))