Skip to content

Commit

Permalink
chore: add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kangmingtay committed Dec 12, 2024
1 parent 59df040 commit 039727d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/GoTrueClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1425,7 +1425,11 @@ export default class GoTrueClient {
if (!isBrowser()) throw new AuthImplicitGrantRedirectError('No browser detected.')

const params = parseParametersFromURL(window.location.href)

// If there's an error in the URL, it doesn't matter what flow it is, we just return the error.
if (params.error || params.error_description || params.error_code) {
// The error class returned implies that the redirect is from an implicit grant flow
// but it could also be from a redirect error from a PKCE flow.
throw new AuthImplicitGrantRedirectError(
params.error_description || 'Error in URL with unspecified error_description',
{
Expand All @@ -1435,6 +1439,7 @@ export default class GoTrueClient {
)
}

// Checks for mismatches between the flowType initialised in the client and the URL parameters
if (this.flowType === 'implicit' && !this._isImplicitGrantFlow()) {
throw new AuthImplicitGrantRedirectError('Not a valid implicit grant flow url.')
} else if (this.flowType == 'pkce' && !isPKCEFlow) {
Expand Down

0 comments on commit 039727d

Please sign in to comment.