1
我對魔法寶石有點問題。當我登錄到我的應用程序時,控制器成功登錄,然後將我重定向到另一個頁面(我可以確定登錄憑據是正確的,就好像它們不是呈現登錄頁面操作而不是重定向地點)。但是,當應用程序嘗試加載此頁面時,Sorcery的requires_login
方法失敗,因爲current_user
返回false(然後觸發not_authenticated
並將我引導回首頁)。魔法師的current_user方法在生產中登錄後返回false直接
這隻發生在生產中,如果我在開發中運行網站,一切正常。我嘗試刪除所有運行的其他before_filters
,但仍然遇到同樣的問題,所以它不在那裏。
登錄由下列控制器動作處理(我不認爲那裏面有什麼是負責任的,但以防萬一):
# user_sessions_controller.rb
def create
logout
@user = login(params[:email], params[:password])
if @user
@user.assign_locale(params[:locale])
flash[:success] = "Log in successful."
if can? :read, Organisation
redirect_to some_path
else
redirect_to another_path
end
else
flash.now[:error] = "Unrecognised email/password combination"
render "new"
end
end