Sha256: 7729d0ca13cc4df0ec3c8ebe895127ce33140e9cc413ff1121abe481c3372f17

Contents?: true

Size: 1.47 KB

Versions: 10

Compression:

Stored size: 1.47 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].each do |action|
          conf.send(action).columns.exclude :remember_created_at
        end
        conf.list.columns = %i[email administrator created_at confirmed_at]
      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

10 entries across 10 versions & 1 rubygems

Version Path
eac_users_support-0.9.7 app/controllers/eac_users_support/admin/users_controller.rb
eac_users_support-0.9.6 app/controllers/eac_users_support/admin/users_controller.rb
eac_users_support-0.9.5 app/controllers/eac_users_support/admin/users_controller.rb
eac_users_support-0.9.4 app/controllers/eac_users_support/admin/users_controller.rb
eac_users_support-0.9.3 app/controllers/eac_users_support/admin/users_controller.rb
eac_users_support-0.9.2 app/controllers/eac_users_support/admin/users_controller.rb
eac_users_support-0.9.1 app/controllers/eac_users_support/admin/users_controller.rb
eac_users_support-0.9.0 app/controllers/eac_users_support/admin/users_controller.rb
eac_users_support-0.8.7 app/controllers/eac_users_support/admin/users_controller.rb
eac_users_support-0.8.6 app/controllers/eac_users_support/admin/users_controller.rb