Sha256: afbfd4db359ae128f4ccf4b66a6d8e970f75a1d4b7fbe77191230fbe2e636fc0

Contents?: true

Size: 687 Bytes

Versions: 23

Compression:

Stored size: 687 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
  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.find_by uid: params[:id]
  end

  def set_new_user!
    @user = User.new user_params
  end

end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
mumuki-laboratory-5.2.0 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-5.1.1 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-5.1.0 app/controllers/concerns/users_controller_template.rb