Skip to content

Commit 311c8c2

Browse files
chkuang-ga-maurice
authored andcommitted
Update auth token before sending it when the connection is established.
Current we send auth token to server whenever get/set (put/listen) request is queue, if the connection has been established. It is not a very nice implementation and more changes will be made in b/123781317 This change would fix a bug if the event happens in the following order. - Auth sign-in. - auto db = Database::GetInstance(); (Create database, start connecting to server) - db.GetReference().SetValue(1); (Put request added, and queue as pending request. But no token sent because connection is not established yet) - Connection established. OnReady() called. Since it does not retrieve auth_token_ at this point, no auth token would be sent to the server. - Pending put requests sent before auth token message is sent => may result in permission deny. PiperOrigin-RevId: 246432366
1 parent a90d8db commit 311c8c2

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

database/src/desktop/connection/persistent_connection.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ void PersistentConnection::OnReady(int64_t timestamp,
187187
LogDebug("%s calling restore state", log_id_.c_str());
188188
assert(connection_state_ == kConnecting);
189189

190+
// Try to retrieve auth token synchronously when connection is ready.
191+
GetAuthToken(&auth_token_);
192+
190193
if (auth_token_.empty()) {
191194
LogDebug("%s Not restoring auth because token is null.", log_id_.c_str());
192195
connection_state_ = kConnected;

0 commit comments

Comments
 (0)