Skip to content

Commit

Permalink
Added a new variable in AuthRepsonse "IsFromCache"
Browse files Browse the repository at this point in the history
Added a new response "IsFromCache"
This will be true only when we are reading the response from storage.
  • Loading branch information
4gust committed Aug 6, 2024
1 parent 004301c commit 13b262d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion apps/internal/base/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ type AuthResult struct {
ExpiresOn time.Time
GrantedScopes []string
DeclinedScopes []string
IsFromCache bool
}

// AuthResultFromStorage creates an AuthResult from a storage token response (which is generated from the cache).
Expand All @@ -109,7 +110,7 @@ func AuthResultFromStorage(storageTokenResponse storage.TokenResponse) (AuthResu
return AuthResult{}, fmt.Errorf("problem decoding JWT token: %w", err)
}
}
return AuthResult{account, idToken, accessToken, storageTokenResponse.AccessToken.ExpiresOn.T, grantedScopes, nil}, nil
return AuthResult{account, idToken, accessToken, storageTokenResponse.AccessToken.ExpiresOn.T, grantedScopes, nil, true}, nil
}

// NewAuthResult creates an AuthResult.
Expand All @@ -123,6 +124,7 @@ func NewAuthResult(tokenResponse accesstokens.TokenResponse, account shared.Acco
AccessToken: tokenResponse.AccessToken,
ExpiresOn: tokenResponse.ExpiresOn.T,
GrantedScopes: tokenResponse.GrantedScopes.Slice,
IsFromCache: false,
}, nil
}

Expand Down

0 comments on commit 13b262d

Please sign in to comment.