react-admin-firebase icon indicating copy to clipboard operation
react-admin-firebase copied to clipboard

Set resource collection based on user

Open 7200rpm opened this issue 4 years ago • 4 comments

Hi,

I'd like to be able to set my resource collection based on the logged in user (e.g. users/Jane), but can't seem to figure out a way to do this easily. I see you can set the rootref in the options, but this would only be static. I need to set this dynamically based on who is logging in..

Seems like this would be a common use case where someone has different documents for each user. Am I missing something?

Thanks!

7200rpm avatar Jul 20 '20 02:07 7200rpm

In other words, do you want to create and control the firestore collection of users accessed via Authentication?

splex7 avatar Jul 27 '20 06:07 splex7

In other words, do you want to create and control the firestore collection of users accessed via Authentication?

Yes, and access only the resources that are owned by the logged in user.

7200rpm avatar Aug 03 '20 23:08 7200rpm

Hey @7200rpm, I agree that this would be a very useful feature. I think this issue is a more general version of our problem: https://github.com/benwinding/react-admin-firebase/issues/7. Essentially, accessing a resource sub-collection under the user (e.g. users/Jane/some-sub-collection) is not possible under react-admin-firebase yet.

seranotannason avatar Aug 17 '20 05:08 seranotannason

@7200rpm. There is no user collection base on Firebase Authentication.In my case, when a user is created through Firebase Authentication, the function is triggered to create a new document in the users collection of firestore with the corresponding email. this may help you https://bigcodenerd.org/create-user-profile-firestore-authentication/

splex7 avatar Aug 20 '20 06:08 splex7