配置authlogic以“用户名”或“电子邮件”登录(configure authlogic to log in with “username” OR “email”)

编程入门 行业动态 更新时间:2024-10-26 11:27:55
配置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 model

Did you try this:

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

and 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

更多推荐

本文发布于:2023-07-30 08:03:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1336705.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:电子邮件   用户名   authlogic   configure   email

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!