+ async unbanUsers (users: User[]) {
+ const message = this.i18n('Do you really want to unban {{num}} users?', { num: users.length })
+
+ const res = await this.confirmService.confirm(message, this.i18n('Unban'))
+ if (res === false) return
+
+ this.userService.unbanUsers(users)
+ .subscribe(
+ () => {
+ const message = this.i18n('{{num}} users unbanned.', { num: users.length })
+
+ this.notifier.success(message)
+ this.loadData()
+ },
+
+ err => this.notifier.error(err.message)
+ )
+ }
+
+ async removeUsers (users: User[]) {
+ for (const user of users) {
+ if (user.username === 'root') {
+ this.notifier.error(this.i18n('You cannot delete root.'))
+ return
+ }
+ }
+
+ const message = this.i18n('If you remove these users, you will not be able to create others with the same username!')
+ const res = await this.confirmService.confirm(message, this.i18n('Delete'))
+ if (res === false) return
+
+ this.userService.removeUser(users).subscribe(
+ () => {
+ this.notifier.success(this.i18n('{{num}} users deleted.', { num: users.length }))
+ this.loadData()
+ },
+
+ err => this.notifier.error(err.message)
+ )
+ }
+
+ async setEmailsAsVerified (users: User[]) {
+ this.userService.updateUsers(users, { emailVerified: true }).subscribe(
+ () => {
+ this.notifier.success(this.i18n('{{num}} users email set as verified.', { num: users.length }))
+ this.loadData()
+ },
+
+ err => this.notifier.error(err.message)
+ )
+ }
+
+ isInSelectionMode () {
+ return this.selectedUsers.length !== 0
+ }
+