Sha256: 1ac48abba1b0a8e43998ef32762cc2322f92619f6e62249a5adbb11792434504

Contents?: true

Size: 1.41 KB

Versions: 16

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true

module EacUsersSupport
  module Admin
    class UsersController < ::EacUsersSupport::ApplicationController
      record_select per_page: 10,
                    search_on: %i[email],
                    order_by: 'email ASC',
                    model: ::EacUsersSupport::User,
                    full_text_search: true

      active_scaffold ::EacUsersSupport::User do |conf|
        conf.action_links.add :password_reset,
                              type: :member, method: :put, position: false,
                              label: ::I18n.t(:'eac_users_support.password_reset.action')
        conf.columns.exclude :encrypted_password
        %w[create update list].each do |action|
          conf.send(action).columns.exclude :remember_created_at
        end
      end

      def password_reset
        process_action_link_action do |record|
          record.password = ::Devise.friendly_token
          if record.save
            flash[:info] = ::I18n.t(:'eac_users_support.password_reset.successful',
                                    user: record, password: record.password)
          else
            flash[:error] = ::I18n.t(:'eac_users_support.password_reset.failed', user: user) +
                            ': ' + record.errors.to_s
          end
        end
      end

      protected

      def before_create_save(record)
        record.password = record.email
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
eac_users_support-0.8.5 app/controllers/eac_users_support/admin/users_controller.rb
eac_users_support-0.8.4 app/controllers/eac_users_support/admin/users_controller.rb
eac_users_support-0.8.3 app/controllers/eac_users_support/admin/users_controller.rb
eac_users_support-0.8.2 app/controllers/eac_users_support/admin/users_controller.rb
eac_users_support-0.8.1 app/controllers/eac_users_support/admin/users_controller.rb
eac_users_support-0.8.0 app/controllers/eac_users_support/admin/users_controller.rb
eac_users_support-0.7.1 app/controllers/eac_users_support/admin/users_controller.rb
eac_users_support-0.7.0 app/controllers/eac_users_support/admin/users_controller.rb
eac_users_support-0.6.1 app/controllers/eac_users_support/admin/users_controller.rb
eac_users_support-0.6.0 app/controllers/eac_users_support/admin/users_controller.rb
eac_users_support-0.5.1 app/controllers/eac_users_support/admin/users_controller.rb
eac_users_support-0.5.0 app/controllers/eac_users_support/admin/users_controller.rb
eac_users_support-0.4.0 app/controllers/eac_users_support/admin/users_controller.rb
eac_users_support-0.3.4 app/controllers/eac_users_support/admin/users_controller.rb
eac_users_support-0.3.3 app/controllers/eac_users_support/admin/users_controller.rb
eac_users_support-0.3.2 app/controllers/eac_users_support/admin/users_controller.rb