Skip to content

Commit

Permalink
Revert "fix: Revert "fix: getUser returns null if there is no sessi…
Browse files Browse the repository at this point in the history
…on (#876…"

This reverts commit 6755fef.
  • Loading branch information
hf authored Apr 25, 2024
1 parent a26f771 commit b54eae0
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 @@ -1174,6 +1174,11 @@ export default class GoTrueClient {
throw error
}

if (!data.session?.access_token) {
// if there's no access token, the user can't be fetched
return { data: { user: null }, error: new AuthSessionMissingError() }
}

return await _request(this.fetch, 'GET', `${this.url}/user`, {
headers: this.headers,
jwt: data.session?.access_token ?? undefined,
Expand Down

0 comments on commit b54eae0

Please sign in to comment.