Sha256: 7163ece22467276e598e03dcb5d4006a1dc0f86f3e38331f8cd39c48e4d1be37

Contents?: true

Size: 1.46 KB

Versions: 26

Compression:

Stored size: 1.46 KB

Contents

# frozen_string_literal: true

# generado con pg_rails

module Admin
  class UsersController < AdminController
    include PgEngine::Resource

    before_action { @clase_modelo = User }

    before_action(only: :index) { authorize User }

    before_action only: %i[update] do
      params[:user].delete(:password) if params[:user][:password].blank?
    end

    before_action :set_instancia_modelo, only: %i[new create show edit update destroy]

    add_breadcrumb User.nombre_plural, :admin_users_path

    def create
      @user.skip_confirmation!
      pg_respond_create
    end

    def update
      @user.skip_reconfirmation!
      pg_respond_update
    end

    # TODO: sacar este método a otro lado, que no sea AdminController
    skip_before_action :authenticate_user!, only: [:login_as]

    # :nocov:
    def login_as
      return unless dev_user_or_env?

      usuario = User.find(params[:id])
      if usuario.confirmed_at.present?
        sign_in(:user, usuario)
        redirect_to after_sign_in_path_for(usuario)
      else
        go_back('No está confirmado')
      end
    end
    # :nocov:

    private

    def atributos_permitidos
      %i[email nombre apellido password developer]
    end

    def atributos_para_buscar
      %i[email nombre apellido developer]
    end

    def atributos_para_listar
      %i[email nombre apellido confirmed_at developer]
    end

    def atributos_para_mostrar
      %i[email nombre apellido confirmed_at developer]
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
pg_rails-7.0.8.pre.alpha.111 pg_engine/app/controllers/admin/users_controller.rb
pg_rails-7.0.8.pre.alpha.110 pg_engine/app/controllers/admin/users_controller.rb
pg_rails-7.0.8.pre.alpha.109 pg_engine/app/controllers/admin/users_controller.rb
pg_rails-7.0.8.pre.alpha.108 pg_engine/app/controllers/admin/users_controller.rb
pg_rails-7.0.8.pre.alpha.107 pg_engine/app/controllers/admin/users_controller.rb
pg_rails-7.0.8.pre.alpha.106 pg_engine/app/controllers/admin/users_controller.rb
pg_rails-7.0.8.pre.alpha.105 pg_engine/app/controllers/admin/users_controller.rb
pg_rails-7.0.8.pre.alpha.104 pg_engine/app/controllers/admin/users_controller.rb
pg_rails-7.0.8.pre.alpha.103 pg_engine/app/controllers/admin/users_controller.rb
pg_rails-7.0.8.pre.alpha.102 pg_engine/app/controllers/admin/users_controller.rb
pg_rails-7.0.8.pre.alpha.101 pg_engine/app/controllers/admin/users_controller.rb
pg_rails-7.0.8.pre.alpha.100 pg_engine/app/controllers/admin/users_controller.rb
pg_rails-7.0.8.pre.alpha.99 pg_engine/app/controllers/admin/users_controller.rb
pg_rails-7.0.8.pre.alpha.98 pg_engine/app/controllers/admin/users_controller.rb
pg_rails-7.0.8.pre.alpha.97 pg_engine/app/controllers/admin/users_controller.rb
pg_rails-7.0.8.pre.alpha.96 pg_engine/app/controllers/admin/users_controller.rb
pg_rails-7.0.8.pre.alpha.95 pg_engine/app/controllers/admin/users_controller.rb
pg_rails-7.0.8.pre.alpha.94 pg_engine/app/controllers/admin/users_controller.rb
pg_rails-7.0.8.pre.alpha.93 pg_engine/app/controllers/admin/users_controller.rb
pg_rails-7.0.8.pre.alpha.92 pg_engine/app/controllers/admin/users_controller.rb