supabase / gotrue-dart

A dart client library for GoTrue.
MIT License
46 stars 37 forks source link

currentSession.user is not updated in GoTrueClient.update() #39

Closed bentesha closed 2 years ago

bentesha commented 3 years ago

Only currentUser is updated in the GoTrueClient.update() method. The currentSession.user property is not updated. This leads to a discrepancy between these two sources of truth which should always be in sync.

/// Updates user data, if there is a logged in user.
  Future<GotrueUserResponse> update(UserAttributes attributes) async {
    if (currentSession?.accessToken == null) {
      final error = GotrueError('Not logged in.');
      return GotrueUserResponse(error: error);
    }

    final response =
        await api.updateUser(currentSession!.accessToken, attributes);
    if (response.error != null) return response;

    currentUser = response.user;
    _notifyAllSubscribers(AuthChangeEvent.userUpdated);

    return response;
  }