Sha256: d7a6c071c5aa03bb0a1464972434ed7dca4cb965c802bee5882bb5fab921393c
Contents?: true
Size: 942 Bytes
Versions: 39
Compression:
Stored size: 942 Bytes
Contents
# frozen_string_literal: true module Decidim module Admin # A command to remove the admin privilege to an user. class RemoveAdmin < Rectify::Command # Public: Initializes the command. # # user - the user that will no longer be an admin # current_user - the user that performs the action def initialize(user, current_user) @user = user @current_user = current_user end def call return broadcast(:invalid) unless user Decidim.traceability.perform_action!( "remove_from_admin", user, current_user, extra: { invited_user_role: user_role } ) do user.update!(admin: false, roles: []) end broadcast(:ok) end private attr_reader :user, :current_user def user_role user.admin? ? :admin : user.roles.last end end end end
Version data entries
39 entries across 39 versions & 1 rubygems