-
Notifications
You must be signed in to change notification settings - Fork 28
Description
Has your issue been reported?
- I have searched the existing issues and confirm it has not been reported.
- I give permission for members of the FlutterFlow team to access and test my project for the sole purpose of investigating this issue.
Current Behavior
The app has login via JWT with the "Create User Document" option enabled. Recently, when a user tries to log in sometimes randomly his user document is overwritten, even though the user document exists already, by the fields mentioned in the "Create User Document" description. This happens especially when you clear the cache and try to log in again. This issue only occurs on the Web. I have confirmed this issue by changing the code as below:
// Creates a Firestore document representing the logged in user if it doesn't yet exist
Future maybeCreateUser(User user) async {
final userRecord = UsersRecord.collection.doc(user.uid);
final userExists = await userRecord.get().then((u) => u.exists);
if (userExists) {
currentUserDocument = await UsersRecord.getDocumentOnce(userRecord);
return;
}
final userData = createUsersRecordData(
email: user.email,
displayName: user.displayName,
photoUrl: user.photoURL,
uid: user.uid,
phoneNumber: user.phoneNumber,
createdTime: getCurrentTimestamp,
);
print('Login User being set $userData'); //added this
await userRecord.set(userData, SetOptions(merge: true)); // set merge to true to prevent overwrite
currentUserDocument = UsersRecord.getDocumentFromData(userData, userRecord);
}
On the console the message has been printed there meaning the document ahs been overwritten even though the user document already exists.

The user document created_time has been also updated, if not for the above updated code it would have been wiped out except for a few fields.

Expected Behavior
Login normally without any side effects.
Steps to Reproduce
- Create a basic login page
- Login via JWT with the "Create User Document" option enabled.
- For an existing user, login - logout and login, clear cache, and log in again multiple times as this issue is random. Test this on web.
- Check if the user document has been overwritten.
Reproducible from Blank
- The steps to reproduce above start from a blank project.
Bug Report Code (Required)
IT48l/HLuMlOxLhc+KqNdcdKqCYWHHk7aIJIjdZTY008KOPdOoYUP8+kM0RBTbC8d2w7IUyZkWoW0MLFv+PLFPEDGzeVRZxbws92dArKc3Ojbr3RFJWgPHFADe5nBWaZyKTUsyZdKtBYSnw63Tuyf96QaBPUHr7RNlcGD6/LZO4=
Context
Trying to log in normally but instead end up losing user data.
Visual documentation
Additional Info
No response
Environment
- FlutterFlow version:v3.1 (released July 27, 2023)
- Platform: Web
- Browser name and version: Chrome 115.0.5790.114 (Official Build) (arm64)
- Operating system and version affected: