Hi Rails Guru, Currently I am working i my project, and that project using
rails_api gem. I want to add session management for authentication, but it
seems the session does not working. Here is my configuration in
config/initializer/session_store.rb:
Pmcapi::Application.config.session_store :cookie_store, {
key: ''_pmcapi_session'',
expire_after: 1.hour
}
And I add config.api_only = false in application.rb (
http://stackoverflow.com/questions/15342710/adding-cookie-session-store-back-to-rails-api-app
)
and in my session_controller, I adding session to store token
(in 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
Please, i need help. I have stucked with this, thanks
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/446165d3-e565-4c72-89d5-be66d4c6ecd8%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.