Sha256: f415f44bbe68122e21f96ac3e28efd1728809b36303c589aaac35f49c97e31eb

Contents?: true

Size: 967 Bytes

Versions: 1

Compression:

Stored size: 967 Bytes

Contents

module Zetto::Services::Authentication

  class FindUser

    include Zetto::Modules::Crypto

    def initialize(class_name, name, password)
      @user_class = Zetto::Config::Params.user_class(class_name)
      access_attributes = [Zetto::Config::Params.user_class_name, Zetto::Config::Params.user_class_password]
      unless @user_class.column_names & access_attributes == access_attributes
        raise ArgumentError.new(I18n.t('exseptions.attributes_is_not_defined'))
      end

      @name = name
      @password = password
    end

    def execute
      name = Zetto::Config::Params.user_class_name
      password = Zetto::Config::Params.user_class_password
      @user_class.where("#{name} = ? AND #{password} = ?", @name, @password).first
    rescue Exception => e
      Zetto::Services::Info.error_message I18n.t('exseptions.unknown_error', argument: 'Zetto::Services::Authentication::FindUser', current_method: __method__), e
      nil
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
zetto-2.2.0 lib/zetto/services/authentication/find_user.rb