配置authlogic以“用户名”或“电子邮件”登录(configure authlogic to log in with “username” OR “email”)
我为我的认证系统实施了authlogic。 我希望是否有方法通过“用户名”或“电子邮件”登录用户。 此处提供的解决方案http://goo.gl/Ato1不起作用,因为我在数据库中没有“登录”字段。
那么,我错过了数据库中的“登录”字段? 或者有没有其他的方式来处理它?
登录应通过用户名或电子邮件...
I implemented authlogic for my authentication system. I was hoping if there was a method to log in users by "username" OR "email" . The solution provided here http://goo.gl/Ato1 doesn't work as I don't have a "login" field in the database.
So is it that, I am missing the "login" field in the db? OR is there any other way of handling it?
Login should happen by Username OR email...
最满意答案
你试过这个:
class UserSession < Authlogic::Session::Base find_by_login_method :find_by_username_or_email end并在user.rb中
def self.find_by_username_or_email(login) find_by_username(login) || find_by_email(login) end #note login is only the parameter name and does not refer to your modelDid you try this:
class UserSession < Authlogic::Session::Base find_by_login_method :find_by_username_or_email endand in user.rb
def self.find_by_username_or_email(login) find_by_username(login) || find_by_email(login) end #note login is only the parameter name and does not refer to your model更多推荐
发布评论