Skip to content

Commit bdd485d

Browse files
cynthiajianga-maurice
authored andcommitted
[Auth][desktop] Save user data after reauth and update user info
PiperOrigin-RevId: 264923297
1 parent 9237761 commit bdd485d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

auth/src/desktop/user_desktop.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,13 @@ void CompleteSetAccountInfoPromise(Promise<SignInResult>* const promise,
231231
promise->CompleteWithResult(result);
232232
}
233233

234+
void TriggerSaveUserFlow(AuthData* const auth_data) {
235+
auto auth_impl = static_cast<AuthImpl*>(auth_data->auth_impl);
236+
if (auth_impl != nullptr) {
237+
auth_impl->user_data_persist->SaveUserData(auth_data);
238+
}
239+
}
240+
234241
template <typename ResultT>
235242
void PerformSetAccountInfoFlow(
236243
AuthDataHandle<ResultT, SetAccountInfoRequest>* const handle) {
@@ -240,6 +247,8 @@ void PerformSetAccountInfoFlow(
240247
if (account_info.IsValid()) {
241248
User* api_user_to_return =
242249
account_info.MergeToCurrentUser(handle->auth_data);
250+
251+
TriggerSaveUserFlow(handle->auth_data);
243252
CompleteSetAccountInfoPromise(&handle->promise, api_user_to_return);
244253
} else {
245254
SignOutIfUserNoLongerValid(handle->auth_data->auth, account_info.error());
@@ -367,6 +376,8 @@ void PerformReauthFlow(AuthDataHandle<FutureResultT, RequestT>* const handle) {
367376
if (auth_result.uid() == current_uid) {
368377
const SignInResult sign_in_result =
369378
auth_result.SetAsCurrentUser(handle->auth_data);
379+
380+
TriggerSaveUserFlow(handle->auth_data);
370381
CompletePromise(&handle->promise, sign_in_result);
371382
} else {
372383
FailPromise(&handle->promise, kAuthErrorUserMismatch);

0 commit comments

Comments
 (0)