about summary refs log tree commit diff
path: root/app/controllers/admin/accounts_controller.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-11-07 19:06:44 +0100
committerGitHub <noreply@github.com>2017-11-07 19:06:44 +0100
commit1032f3994fdbd61c2f517057261ddc3559199b6b (patch)
treed039701515efc050dbf91124e8d32da2014498fb /app/controllers/admin/accounts_controller.rb
parentcbbeec05be5cd0930a7be73bf673acc8d8105c12 (diff)
Add ability to disable login and mark accounts as memorial (#5615)
Fix #5597
Diffstat (limited to 'app/controllers/admin/accounts_controller.rb')
-rw-r--r--app/controllers/admin/accounts_controller.rb22
1 files changed, 21 insertions, 1 deletions
diff --git a/app/controllers/admin/accounts_controller.rb b/app/controllers/admin/accounts_controller.rb
index ffa4dc850..7503b880d 100644
--- a/app/controllers/admin/accounts_controller.rb
+++ b/app/controllers/admin/accounts_controller.rb
@@ -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