diff options
Diffstat (limited to 'client/src/app/shared/moderation')
-rw-r--r-- | client/src/app/shared/moderation/user-moderation-dropdown.component.ts | 25 |
1 files changed, 24 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' | |||
4 | import { DropdownAction } from '@app/shared/buttons/action-dropdown.component' | 4 | import { DropdownAction } from '@app/shared/buttons/action-dropdown.component' |
5 | import { UserBanModalComponent } from '@app/shared/moderation/user-ban-modal.component' | 5 | import { UserBanModalComponent } from '@app/shared/moderation/user-ban-modal.component' |
6 | import { UserService } from '@app/shared/users' | 6 | import { UserService } from '@app/shared/users' |
7 | import { AuthService, ConfirmService } from '@app/core' | 7 | import { AuthService, ConfirmService, ServerService } from '@app/core' |
8 | import { User, UserRight } from '../../../../../shared/models/users' | 8 | import { User, UserRight } from '../../../../../shared/models/users' |
9 | import { Account } from '@app/shared/account/account.model' | 9 | import { Account } from '@app/shared/account/account.model' |
10 | import { BlocklistService } from '@app/shared/blocklist' | 10 | import { 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 | } |