Sha256: 85be61ca7c1b19bd95334750bb9b0c038cd7de008482f1c46dd60e073ba86df9

Contents?: true

Size: 491 Bytes

Versions: 5

Compression:

Stored size: 491 Bytes

Contents

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

    def model_name
      User
    end

    def validate(params)
      (!model.new_record? && model.authenticate(params[:password])).tap do |result|
        add_wrong_email_or_password_error unless result
      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

5 entries across 5 versions & 1 rubygems

Version Path
tramway-auth-1.1.0.1 app/forms/tramway/auth/session_form.rb
tramway-auth-1.1 app/forms/tramway/auth/session_form.rb
tramway-auth-1.0.2.1 app/forms/tramway/auth/session_form.rb
tramway-auth-1.0.2 app/forms/tramway/auth/session_form.rb
tramway-auth-1.0.1.2 app/forms/tramway/auth/session_form.rb