|
2 | 2 |
|
3 | 3 | module Admin |
4 | 4 | class AccountsController < BaseController |
5 | | - before_action :set_account, only: [:show, :subscribe, :unsubscribe, :redownload, :remove_avatar, :remove_header, :enable, :unsilence, :unsuspend, :memorialize] |
| 5 | + before_action :set_account, only: [:show, :subscribe, :unsubscribe, :redownload, :remove_avatar, :remove_header, :enable, :unsilence, :unsuspend, :memorialize, :approve, :reject] |
6 | 6 | before_action :require_remote_account!, only: [:subscribe, :unsubscribe, :redownload] |
7 | | - before_action :require_local_account!, only: [:enable, :memorialize] |
| 7 | + before_action :require_local_account!, only: [:enable, :memorialize, :approve, :reject] |
8 | 8 |
|
9 | 9 | def index |
10 | 10 | authorize :account, :index? |
@@ -45,6 +45,18 @@ def enable |
45 | 45 | redirect_to admin_account_path(@account.id) |
46 | 46 | end |
47 | 47 |
|
| 48 | + def approve |
| 49 | + authorize @account.user, :approve? |
| 50 | + @account.user.approve! |
| 51 | + redirect_to admin_accounts_path(pending: '1') |
| 52 | + end |
| 53 | + |
| 54 | + def reject |
| 55 | + authorize @account.user, :reject? |
| 56 | + SuspendAccountService.new.call(@account, including_user: true, destroy: true) |
| 57 | + redirect_to admin_accounts_path(pending: '1') |
| 58 | + end |
| 59 | + |
48 | 60 | def unsilence |
49 | 61 | authorize @account, :unsilence? |
50 | 62 | @account.unsilence! |
@@ -114,6 +126,7 @@ def filter_params |
114 | 126 | :remote, |
115 | 127 | :by_domain, |
116 | 128 | :active, |
| 129 | + :pending, |
117 | 130 | :silenced, |
118 | 131 | :suspended, |
119 | 132 | :username, |
|
0 commit comments