Can't put email address field on login form (Authlogic)

后端 未结 7 1421
北恋
北恋 2021-01-31 11:47

So I have Authlogic working fine with this user_sessions/new view:

<% form_for @user_session, :url => user_session_path do |f| %>

  <%          


        
7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-31 12:28

    You are going about this the wrong way:

    Try:

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

    and in user.rb

    def self.find_by_login_or_email(login)
       find_by_login(login) || find_by_email(login)
    end
    

    Your UserSession has no concept of email (it just knows about login).

    It runs through a process of finding a User given a login, which you can intercept and override (with the find_by_login_method). For an added bonus you can also override, login_field and password_field or even verify_password_method

提交回复
热议问题