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.11.0 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-5.10.4 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-5.10.3 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-5.10.2 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-5.10.1 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-5.10.0 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-5.9.1 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-5.9.0 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-5.8.3 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-5.8.1 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-5.8.0 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-5.7.0 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-5.6.3 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-5.6.2 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-5.6.1 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-5.6.0 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-5.5.0 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-5.4.0 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-5.3.0 app/controllers/concerns/users_controller_template.rb
mumuki-laboratory-5.2.1 app/controllers/concerns/users_controller_template.rb