-
Notifications
You must be signed in to change notification settings - Fork 307
Closed
Description
Seems like a common flow I see for defining admin users is to have an admin collection, and then you can check the authenticated user against that collection to make a determination.
Since hooks can't show conditionally, the syntax for doing this seems to be along the lines of:
const { initializing, user } = useAuthState(auth);
const { loading, error, value } = useDocument(db.doc(`admins/${ user && user.email }`));
...
const isAdmin = !!value.exists;
In this case, we begin by querying via useDocument
for a document we know won't work (admins/
), but it of course works fine when user.email
is available.
Is there a better way of doing this with hooks and firebase?
Metadata
Metadata
Assignees
Labels
No labels