下面是我的用户会话控制器创建登录所经历的操作
# POST /resource/sign_in
def create
resource = User.find_by_email(params[:user][:email])
# check for inactive
redirect_to(new_user_session_path, :notice => 'Invalid Email Address or Password.') and return if resource.try(:active) == false
# check to see if user is AD user
if ad_resource?(resource)
if !ActiveDirectory.new.authenticate!(params[:user][:email], params[:user][:password])
redirect_to new_user_session_path, :notice => 'Invalid Email Address or Password.'
return
end
else
resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new")
end
set_flash_message :notice, :signed_in
sign_in_and_redirect(resource_name, resource)
end这一行
resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new")如何可能登录任何人……我不熟悉设计,我正在尝试登录,我知道数据库中有活动用户,但我无法登录,看着warden.authenticate行会让我感到困惑,因为它没有在电子邮件和password...any帮助中传递,这将有助于我了解身份验证过程中发生的事情
发布于 2012-02-13 22:25:47
有一个看守初始化器文件,它作为中间件运行,当与devise一起使用时,它会获得正确的参数。
看一看warden gem以全面了解它是如何工作的。
就我个人而言,我发现devise很快就会成为障碍,如果你“滚动”自己的认证系统,你可能会更好地理解它是如何工作的。
https://stackoverflow.com/questions/9261951
复制相似问题