Sha256: ea274260ac09d19ad440f159e43bc67bc4c002ed2567185a2b1ffecd450d85d6

Contents?: true

Size: 686 Bytes

Versions: 18

Compression:

Stored size: 686 Bytes

Contents

module UsersControllerTemplate
  extend ActiveSupport::Concern

  included do
    before_action :set_user!, only: [:show, :update]
    before_action :set_new_user!, only: :create
    before_action :protect_permissions_assignment!, only: [:create, :update]
  end

  private

  def protect_permissions_assignment!
    current_user.protect_permissions_assignment! user_params[:permissions], @user.permissions_was
  end

  def user_params
    params.require(:user).permit(:first_name, :last_name, :email, :image_url, permissions: Mumukit::Auth::Roles::ROLES)
  end

  def set_user!
    @user = User.locate! params[:id]
  end

  def set_new_user!
    @user = User.new user_params
  end

end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
mumuki-laboratory-7.0.3 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-7.0.2 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-6.7.7 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-6.7.6 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-6.7.5 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-7.0.1 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-7.0.0 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-6.7.4 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-6.7.3 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-6.7.2 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-6.7.1 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-6.7.0 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-6.6.1 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-6.6.0 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-6.5.1 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-6.5.0 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-6.4.2 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-6.4.1 app/controllers/concerns/users_controller_template.rb