Skip to content

Commit 042f3c6

Browse files
authored
fix(gotrue): Set _currentUser when setting initial session (supabase#806)
* fix(gotrue): Set _currentUser when setting initial session * Add comment to currentUser to direct people to use currentSession to see if session exists
1 parent e26f79c commit 042f3c6

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/gotrue/lib/src/gotrue_client.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ class GoTrueClient {
120120
Map<String, String> get headers => _headers;
121121

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

125130
/// Returns the current session, if any;
@@ -901,6 +906,7 @@ class GoTrueClient {
901906
}
902907

903908
_currentSession = session;
909+
_currentUser = session.user;
904910
notifyAllSubscribers(AuthChangeEvent.initialSession);
905911
}
906912

0 commit comments

Comments
 (0)