- async unbanUser (user: User) {
- const message = this.i18n('Do you really want to unban {{username}}?', { username: user.username })
- const res = await this.confirmService.confirm(message, this.i18n('Unban'))
- if (res === false) return
-
- this.userService.unbanUser(user)
- .subscribe(
- () => {
- this.notificationsService.success(
- this.i18n('Success'),
- this.i18n('User {{username}} unbanned.', { username: user.username })
- )
- this.loadData()
- },
-
- err => this.notificationsService.error(this.i18n('Error'), err.message)
- )
- }
-
- async removeUser (user: User) {
- if (user.username === 'root') {
- this.notificationsService.error(this.i18n('Error'), this.i18n('You cannot delete root.'))
- return
- }
-
- const message = this.i18n('If you remove this user, you will not be able to create another with the same username!')
- const res = await this.confirmService.confirm(message, this.i18n('Delete'))
- if (res === false) return
-
- this.userService.removeUser(user).subscribe(
- () => {
- this.notificationsService.success(
- this.i18n('Success'),
- this.i18n('User {{username}} deleted.', { username: user.username })
- )
- this.loadData()
- },
-
- err => this.notificationsService.error(this.i18n('Error'), err.message)
- )
- }
-
- getRouterUserEditLink (user: User) {
- return [ '/admin', 'users', 'update', user.id ]
- }
-