Skip to content

Commit

Permalink
fix: getUser returns null if there is no session
Browse files Browse the repository at this point in the history
  • Loading branch information
hf committed Apr 10, 2024
1 parent bd91e72 commit 8c4a6a7
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 @@ -1198,6 +1198,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 8c4a6a7

Please sign in to comment.