0
0
Fork 0

Add ability to disable login and mark accounts as memorial (#5615)

Fix #5597
This commit is contained in:
Eugen Rochko 2017-11-07 19:06:44 +01:00 committed by GitHub
parent cbbeec05be
commit 1032f3994f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 168 additions and 39 deletions

View file

@ -2,8 +2,9 @@
module Admin
class AccountsController < BaseController
before_action :set_account, only: [:show, :subscribe, :unsubscribe, :redownload]
before_action :set_account, only: [:show, :subscribe, :unsubscribe, :redownload, :enable, :disable, :memorialize]
before_action :require_remote_account!, only: [:subscribe, :unsubscribe, :redownload]
before_action :require_local_account!, only: [:enable, :disable, :memorialize]
def index
@accounts = filtered_accounts.page(params[:page])
@ -24,6 +25,21 @@ module Admin
redirect_to admin_account_path(@account.id)
end
def memorialize
@account.memorialize!
redirect_to admin_account_path(@account.id)
end
def enable
@account.user.enable!
redirect_to admin_account_path(@account.id)
end
def disable
@account.user.disable!
redirect_to admin_account_path(@account.id)
end
def redownload
@account.reset_avatar!
@account.reset_header!
@ -42,6 +58,10 @@ module Admin
redirect_to admin_account_path(@account.id) if @account.local?
end
def require_local_account!
redirect_to admin_account_path(@account.id) unless @account.local? && @account.user.present?
end
def filtered_accounts
AccountFilter.new(filter_params).results
end