Trip
Trip

Reputation: 27114

Override authlogic's email validation

I am making a login using AuthLogic, but I would like 'email' to be optional. It seems however that authlogic out of the box makes this validated for. Anyone know a workaround?

Upvotes: 4

Views: 1829

Answers (2)

Austin Lin
Austin Lin

Reputation: 2564

from the authlogic example rails application:

  1. Set up your model

Make sure you have a model that you will be authenticating with. Since we are using the User model it should look something like:

class User < ActiveRecord::Base
  acts_as_authentic do |c|
    c.my_config_option = my_value # for available options see documentation in: Authlogic::ActsAsAuthentic
  end # block optional  
end

One thing to note here is that this tries to take care of all the authentication grunt work, including validating your login, email, password, and token fields. You can easily disable this with configuration. Ex: c.validate_email_field = false. See the Authlogic::ActsAsAuthentic sub modules in the documentation for more details.

Key part to note:

You can easily disable this with configuration. Ex: c.validate_email_field = false.

Hope that helps.

Source: https://github.com/binarylogic/authlogic_example

Upvotes: 7

Related Questions