Skip to content

Commit

Permalink
Modify warden to not store in session
Browse files Browse the repository at this point in the history
Previously, GDTA was storing the authenticated user in the session. This
is likely not what was desired as evidenced by issue #7.

Therefore, this commit changes warden to only sign in a user for that
request. Since the user is not stored in session, the user has to be
pulled from warden (rather than the warden through the session).
  • Loading branch information
mcordell committed Oct 9, 2015
1 parent 365f9ab commit c7c3e4e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/grape_devise_token_auth/auth_headers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class AuthHeaders
extend Forwardable

def initialize(warden, mapping, request_start, data)
@resource = warden.session_serializer.fetch(mapping)
@resource = warden.user(:user)
@request_start = request_start
@data = data
end
Expand Down
2 changes: 1 addition & 1 deletion lib/grape_devise_token_auth/auth_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module AuthHelpers
def self.included(_base)
Devise.mappings.keys.each do |mapping|
define_method("current_#{mapping}") do
warden.session_serializer.fetch(mapping)
warden.user(mapping)
end

define_method("authenticate_#{mapping}") do
Expand Down
2 changes: 1 addition & 1 deletion lib/grape_devise_token_auth/devise_interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def initialize(data)
# extracted and simplified from Devise
def set_user_in_warden(scope, resource)
scope = Devise::Mapping.find_scope!(scope)
warden.session_serializer.store(resource, scope)
warden.set_user(resource, scope: scope, store: false)
end

def mapping_to_class(m)
Expand Down

0 comments on commit c7c3e4e

Please sign in to comment.