Skip to content

Commit

Permalink
fix(gotrue): Set _currentUser when setting initial session (#806)
Browse files Browse the repository at this point in the history
* fix(gotrue): Set _currentUser when setting initial session

* Add comment to currentUser to direct people to use currentSession to see if session exists
  • Loading branch information
dshukertjr committed Jan 22, 2024
1 parent e26f79c commit 042f3c6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/gotrue/lib/src/gotrue_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ class GoTrueClient {
Map<String, String> get headers => _headers;

/// Returns the current logged in user, if any;
///
/// Use [currentSession] to determine whether the user has an active session,
/// because [currentUser] can be non-null without an active session, such as
/// when the user signed up using email and password but has not confirmed
/// their email address.
User? get currentUser => _currentUser;

/// Returns the current session, if any;
Expand Down Expand Up @@ -901,6 +906,7 @@ class GoTrueClient {
}

_currentSession = session;
_currentUser = session.user;
notifyAllSubscribers(AuthChangeEvent.initialSession);
}

Expand Down

0 comments on commit 042f3c6

Please sign in to comment.