Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User metadata not updated in database when registering #1196

Open
p2004a opened this issue Apr 1, 2023 · 0 comments
Open

User metadata not updated in database when registering #1196

p2004a opened this issue Apr 1, 2023 · 0 comments
Assignees

Comments

@p2004a
Copy link

p2004a commented Apr 1, 2023

Describe the bug
When deployed latest (4a077b5) fronted on new empty instance, and created a new user, the user is not visible on the management list at all after joining. After they change settings, they are there, but without email, display name, and with incorrect list of roles.

To Reproduce

  1. Setup independent instance of Rowy
  2. Invite user by email
  3. Used signs in
  4. User is not visible on members lists after signing in
  5. User stop having it's profile picture visible after changing settings

Expected behavior
User is visible on members list with correct information after they sign in.

Additional context

I'm not familiar with the app or React really, but I think I've traced down the issue in the code, and it looks like the order of operation when initializing the React app is incorrect and this code:

user: {
email: currentUser.email || "",
displayName: currentUser.displayName || undefined,
photoURL: currentUser.photoURL || undefined,
phoneNumber: currentUser.phoneNumber || undefined,
},
is never executed, the user field in __rowy__/userManagement/users/${userid}/ is never being set, so the user is incorrectly or not at all visible on the members list etc.

useSettingsDocs is being called, and on the first call, value of currentUser is always undefined, this causes in the call below to useFirestoreDocWithAtom to never initialize the fields in the database.

Later after user changes any settings, it's impossible for this code to execute again because createIfNonExistent won't be called, because something exists there already.

Possible solution

I'm not sure, but it looks to me that changing this invocation:

if (_updateUserSettings) _updateUserSettings({ roles });
to also fill in user details would be a better place to initialize this part of the document. This way, any updates to the user like profile picture or display name should also be properly picked up by the application.

This is how the possible fix looks like: 8d8686a The part I'm not sure there is the scary looking warning about "infinite re-render", but it doesn't work without that change (more race conditions and that's also why user roles list is not getting properly updates in the management list even though it's added there already) and with it there doesn't seem to be anything triggering this infinite re-render and comment doesn't explain because of what this infinite loop was happening.

@p2004a p2004a changed the title User medata not updated in database when registering User metadata not updated in database when registering Apr 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants