From fc2ec87a8c4dcfbb91a1a62cf4c07a2a8e6a50fe Mon Sep 17 00:00:00 2001 From: Josh Morel Date: Wed, 21 Nov 2018 02:48:29 -0500 Subject: enable email verification by admin (#1348) * enable email verification by admin * rename/label to set email as verified to be more explicit that admin is not sending another email to confirm * add update user emailVerified check-params test * make user.model emailVerified property required --- .../users/user-list/user-list.component.html | 12 +++++++++- .../+admin/users/user-list/user-list.component.ts | 26 +++++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) (limited to 'client/src/app/+admin/users') 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 @@ (banned) - {{ user.email }} + {{ user.email }} + + + ? {{ user.email }} + + + + ✓ {{ user.email }} + + + {{ user.videoQuotaUsed }} / {{ user.videoQuota }} {{ user.roleLabel }} {{ user.createdAt }} 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 @@ import { Component, OnInit, ViewChild } from '@angular/core' import { NotificationsService } from 'angular2-notifications' import { SortMeta } from 'primeng/components/common/sortmeta' -import { ConfirmService } from '../../../core' +import { ConfirmService, ServerService } from '../../../core' import { RestPagination, RestTable, UserService } from '../../../shared' import { I18n } from '@ngx-translate/i18n-polyfill' import { User } from '../../../../../../shared' @@ -28,12 +28,17 @@ export class UserListComponent extends RestTable implements OnInit { constructor ( private notificationsService: NotificationsService, private confirmService: ConfirmService, + private serverService: ServerService, private userService: UserService, private i18n: I18n ) { super() } + get requiresEmailVerification () { + return this.serverService.getConfig().signup.requiresEmailVerification + } + ngOnInit () { this.initialize() @@ -51,6 +56,11 @@ export class UserListComponent extends RestTable implements OnInit { label: this.i18n('Unban'), handler: users => this.unbanUsers(users), isDisplayed: users => users.every(u => u.blocked === true) + }, + { + label: this.i18n('Set Email as Verified'), + handler: users => this.setEmailsAsVerified(users), + isDisplayed: users => this.requiresEmailVerification && users.every(u => !u.blocked && u.emailVerified === false) } ] } @@ -114,6 +124,20 @@ export class UserListComponent extends RestTable implements OnInit { ) } + async setEmailsAsVerified (users: User[]) { + this.userService.updateUsers(users, { emailVerified: true }).subscribe( + () => { + this.notificationsService.success( + this.i18n('Success'), + this.i18n('{{num}} users email set as verified.', { num: users.length }) + ) + this.loadData() + }, + + err => this.notificationsService.error(this.i18n('Error'), err.message) + ) + } + isInSelectionMode () { return this.selectedUsers.length !== 0 } -- cgit v1.2.3