Tim*_*Tim 2 ruby-on-rails authlogic ruby-on-rails-3
我在Rails 2.3.5上运行了官方的authlogic插件.我将我的应用程序转换为Rails 3.0.1,现在我遇到了一些问题.
我在我的gemfile中包含了以下authlogic gem
gem 'authlogic', :git => 'git://github.com/odorcicd/authlogic.git', :branch => 'rails3'
用户登录时会保存会话.调用该用户会话时,返回的值为nil.UserSession.find returns a nil value所以我无法分配current_user.
sessions_controller.rb
def create
@user_session = UserSession.new(params[:user_session])
if @user_session.save!
flash[:notice] = 'Login successful'
redirect_to root_url
else
render :action => 'new'
end
end
Run Code Online (Sandbox Code Playgroud)
application_controller.rb
helper_method :current_user, :current_user_session
private
def current_user_session
return @current_user_session if defined?(@current_user_session)
@current_user_session = UserSession.find
end
def current_user
return @current_user if defined?(@current_user)
@current_user = current_user_session && current_user_session.record
end
Run Code Online (Sandbox Code Playgroud)
当用户登录时,将返回闪存通知,'Login sucessful'但未设置current_user.我也尝试使用官方的authlogic插件,没有任何改变.我在这里错过了什么吗?
谢谢!
蒂姆
我有这个确切的问题.出于某种原因,它与基本身份验证干扰 - 修复它,我设置allow_http_basic_auth为false.
class UserSession < Authlogic::Session::Base
allow_http_basic_auth false
end
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
786 次 |
| 最近记录: |