我意识到authenticate_user!
is 没有明确定义 https://stackoverflow.com/questions/9272272/where-is-devise-implementation-of-authenticate-user-method在 gem 文件中,但我想知道典型的应用程序(名为模型的身份验证User
),该方法会是什么样子。我需要知道,以便我可以稍微修改它。
我相信你链接到你自己的答案,它定义的方法是
def authenticate_#{mapping}!(opts={})
opts[:scope] = :#{mapping}
warden.authenticate!(opts) if !devise_controller? || opts.delete(:force)
end
如果我们用你的例子替换真正的类User
,它看起来像:
def authenticate_user!(opts={})
opts[:scope] = :user
warden.authenticate!(opts) if !devise_controller? || opts.delete(:force)
end
因此,它确实需要向典狱长发出请求,而这正是大部分身份验证逻辑所在。
对于典型的 Rails 应用程序,authenticate_user!
方法将被定义为instance_method
on ApplicationController
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)