aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared')
-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
3 files changed, 35 insertions, 1 deletions
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)))