Skip to content

Commit

Permalink
fix: revert check for access token in header (#885)
Browse files Browse the repository at this point in the history
Reverts #882 due to

> One thing to keep in mind is that the Authorization header will always
exist since the anon key is there by default, right? So hasAccessToken
will always be true; which makes this whole section of code useless, and
you might as well go back to no checks.
>
> One thing you could do when the client is created is check if the dev
passed in an Authorization header. If so, set something like
this.hasCustomAuthHeader = true - which would be intialized as false
during client creation.
> 
> Then you could check for that on the right side of || in this getUser
code.
  • Loading branch information
hf committed Apr 25, 2024
1 parent 10e9d38 commit 03d8ba7
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/GoTrueClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1174,8 +1174,7 @@ export default class GoTrueClient {
throw error
}

const hasAccessToken = data.session?.access_token || this.headers['Authorization']
if (!hasAccessToken) {
if (!data.session?.access_token) {
// if there's no access token, the user can't be fetched
return { data: { user: null }, error: new AuthSessionMissingError() }
}
Expand Down

0 comments on commit 03d8ba7

Please sign in to comment.