Sha256: 8a742f7c9d35c5397d5008ae6198c47d7466bd01c6ba78c0569c979a4aef8a6e
Contents?: true
Size: 937 Bytes
Versions: 26
Compression:
Stored size: 937 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 end end end end
Version data entries
26 entries across 26 versions & 1 rubygems