Sha256: 7c2c9cfce9aa7d5b7f8508778682d6e05bd827fa02e30b922271b285589ae1c2

Contents?: true

Size: 973 Bytes

Versions: 12

Compression:

Stored size: 973 Bytes

Contents

module DeviseG5Authenticatable
  module Helpers
    extend ActiveSupport::Concern

    def clear_blank_passwords
      Devise.mappings.keys.each do |scope|
        if params[scope].present?
          password_params(scope).each { |p| clear_blank_param(scope, p) }
        end
      end
    end

    def password_params(scope)
      params[scope].keys.select { |k| k =~ /password/ }
    end

    def clear_blank_param(scope, param_name)
      params[scope].delete(param_name) if params[scope][param_name].blank?
    end

    def handle_resource_error(error)
      resource.errors[:base] << error.message
      respond_with(resource)
    end

    module ClassMethods
      def define_helpers(mapping)
        class_eval <<-METHODS, __FILE__, __LINE__ + 1
          def set_updated_by_#{mapping}
            resource_params = params[:#{mapping}] || params
            resource_params[:updated_by] = current_#{mapping}
          end
        METHODS
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
devise_g5_authenticatable-0.3.0 lib/devise_g5_authenticatable/controllers/helpers.rb
devise_g5_authenticatable-0.2.5.beta lib/devise_g5_authenticatable/controllers/helpers.rb
devise_g5_authenticatable-0.2.4 lib/devise_g5_authenticatable/controllers/helpers.rb
devise_g5_authenticatable-0.2.4.beta lib/devise_g5_authenticatable/controllers/helpers.rb
devise_g5_authenticatable-0.2.3 lib/devise_g5_authenticatable/controllers/helpers.rb
devise_g5_authenticatable-0.2.2 lib/devise_g5_authenticatable/controllers/helpers.rb
devise_g5_authenticatable-0.2.1 lib/devise_g5_authenticatable/controllers/helpers.rb
devise_g5_authenticatable-0.2.0 lib/devise_g5_authenticatable/controllers/helpers.rb
devise_g5_authenticatable-0.1.3 lib/devise_g5_authenticatable/controllers/helpers.rb
devise_g5_authenticatable-0.1.2 lib/devise_g5_authenticatable/controllers/helpers.rb
devise_g5_authenticatable-0.1.1 lib/devise_g5_authenticatable/controllers/helpers.rb
devise_g5_authenticatable-0.1.0 lib/devise_g5_authenticatable/controllers/helpers.rb