Skip to content

Commit

Permalink
Merge pull request #16695 from opf/fix/lost-oauth-tokens
Browse files Browse the repository at this point in the history
Attempt to fix lost oauth token issue.
  • Loading branch information
ba1ash authored Sep 10, 2024
2 parents f9f5833 + 950c779 commit eead77b
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,11 @@ def current_token(storage)
return Failures::Builder.call(code: :error, log_message:, data:)
end

current_token = OAuthClientToken.find_by(user: @user,
oauth_client: storage.oauth_configuration.oauth_client)
# Uncached block is used here because in case of concurrent update on the second try we need a fresh token.
# Otherwise token ends up in an invalid state which leads to an undesired token deletion.
current_token = OAuthClientToken.uncached do
OAuthClientToken.find_by(user: @user, oauth_client: storage.oauth_configuration.oauth_client)
end
if current_token.nil?
Failures::Builder.call(code: :unauthorized,
log_message: "Authorization failed. No user access token found.",
Expand Down

0 comments on commit eead77b

Please sign in to comment.