Skip to content

Commit

Permalink
Merge pull request lynndylanhurley#329 from colavitam/master
Browse files Browse the repository at this point in the history
Fixed error when using standard devise authentication
  • Loading branch information
booleanbetrayal committed Aug 8, 2015
2 parents 14b66a9 + 6bb0999 commit 1c26d0b
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module DeviseTokenAuth::Concerns::SetUserByToken
# keep track of request duration
def set_request_start
@request_started_at = Time.now
@used_auth_by_token = true
end

# user auth
Expand All @@ -31,6 +32,7 @@ def set_user_by_token(mapping=nil)
# check for an existing user, authenticated via warden/devise
devise_warden_user = warden.user(rc.to_s.underscore.to_sym)
if devise_warden_user && devise_warden_user.tokens[@client_id].nil?
@used_auth_by_token = false
@resource = devise_warden_user
@resource.create_new_auth_token
end
Expand Down Expand Up @@ -64,6 +66,9 @@ def update_auth_header
# cannot save object if model has invalid params
return unless @resource and @resource.valid? and @client_id

# Generate new client_id with existing authentication
@client_id = nil unless @used_auth_by_token

if not DeviseTokenAuth.change_headers_on_each_request
auth_header = @resource.build_auth_header(@token, @client_id)

Expand Down

0 comments on commit 1c26d0b

Please sign in to comment.