diff --git a/packages/gotrue/lib/src/gotrue_client.dart b/packages/gotrue/lib/src/gotrue_client.dart index ea626fe04..929f27483 100644 --- a/packages/gotrue/lib/src/gotrue_client.dart +++ b/packages/gotrue/lib/src/gotrue_client.dart @@ -717,7 +717,17 @@ class GoTrueClient { RequestMethodType.get, options: options, ); - return UserResponse.fromJson(response); + final userResponse = UserResponse.fromJson(response); + + if (userResponse.user == null) return userResponse; + + // np need to update the local user when the user is the same + if (userResponse.user == _currentSession?.user) return userResponse; + + _currentSession = currentSession?.copyWith(user: userResponse.user); + notifyAllSubscribers(AuthChangeEvent.userUpdated); + + return userResponse; } /// Updates user data, if there is a logged in user.