views:

536

answers:

2

How do i override/set authlogic to use the email field instead of the username field for both signup and authentication, having a username + an email is occasionally too intense for some some registration scenarios

+4  A: 

If you simply remove the login column and add an email column, authlogic will do the rest.

See this example readme for all the optional/required DB columns.

bensie
magic!. Also i found using this also worked: acts_as_authentic do |c| c.login_field = :email end
ADAM
+1  A: 

better answer try this... well, update authlogic gem if needed!

user_session.rb

class UserSession < Authlogic::Session::Base
  find_by_login_method :find_by_email #for example or you can make what ever method see exapmle 2
end

--- example 2

user_session.rb

class UserSession < Authlogic::Session::Base
  find_by_login_method :find_by_anything
end

user.rb

class User < ActiveRecord::Base
  acts_as_authentic

  def self.find_by_anything(login)
    find_by_login(login) || find_by_email(login) || find_by_id(login)
  end
end
amrnt
thanks for the answer amrnt!
ADAM