logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

roles_controller.rb (584B)


  1. # frozen_string_literal: true
  2. module Admin
  3. class RolesController < BaseController
  4. before_action :set_user
  5. def promote
  6. authorize @user, :promote?
  7. @user.promote!
  8. log_action :promote, @user
  9. redirect_to admin_account_path(@user.account_id)
  10. end
  11. def demote
  12. authorize @user, :demote?
  13. @user.demote!
  14. log_action :demote, @user
  15. redirect_to admin_account_path(@user.account_id)
  16. end
  17. private
  18. def set_user
  19. @user = Account.find(params[:account_id]).user || raise(ActiveRecord::RecordNotFound)
  20. end
  21. end
  22. end