Sha256: f14c7a2d7aa13313b4a62b0a677fe989edb56f55f9d15a808f8e500b3588ea8f

Contents?: true

Size: 523 Bytes

Versions: 2

Compression:

Stored size: 523 Bytes

Contents

module Tramway::Auth
  class SessionForm < ::Tramway::Core::ApplicationForm
    properties :email
    attr_accessor :password 

    def model_name
      User
    end

    def validate(params)
      begin
        add_wrong_email_or_password_error unless self.model.authenticate params[:password]
      rescue
        add_wrong_email_or_password_error
        false
      end
    end

    private

    def add_wrong_email_or_password_error
      errors.add(:email, I18n.t('errors.wrong_email_or_password'))
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tramway-auth-1.0.1.1 app/forms/tramway/auth/session_form.rb
tramway-auth-1.0.1 app/forms/tramway/auth/session_form.rb