【发布时间】:2013-09-26 05:09:37
【问题描述】:
目前我正在我的项目和那个项目中工作 使用 rails_api 宝石。我想为身份验证添加会话管理,但是 它 似乎会话不起作用。这是我的配置 config/initializer/session_store.rb:
Pmcapi::Application.config.session_store :cookie_store, {
key: '_pmcapi_session',
expire_after: 1.hour
}
在我的 session_controller 中,我添加了会话来存储令牌
(在 session_controller.rb 中)
def create
#just to generate new token
user.reset_sso_token!
session[:token] ||= user.sso_token
self.current_user = user
redirect_to root_path
end
when i am in application_controller, i want to access session[:token]
but
the result is nil (in application_controller.rb)
def authenticate_user!
#puts("User Authentication")
#puts(request.authorization)
#puts(request)
@user = User.authenticate_with_token(session[:token])
#head :unauthorized unless @user.present?
redirect_to sign_in_path if @user.nil?
end
拜托,我需要帮助。我一直坚持这个,谢谢
【问题讨论】:
标签: ruby-on-rails ruby session