DEV Community

Cover image for Building Role-Based Authentication with Firebase in a React + Vite SaaS App

Building Role-Based Authentication with Firebase in a React + Vite SaaS App

Anderson Chinedum on October 02, 2026

Authentication looked straightforward when all I needed was a way for users to sign in. It became more interesting while I was building Loomwing, ...
Collapse
 
elijahbrown profile image
Elijah Brown •

The split between Firebase identity, Loomwing profile, and unfinished onboarding is the useful bit. I'd keep the same honesty for contact fields: authenticated does not mean the email domain can receive mail or that the phone has a country attached yet.

Collapse
 
anderson-devvs profile image
Anderson Chinedum •

Hmmm, that's a really good point. I think the authentication/profile/onboarding separation made me realize that I need to be just as careful with contact data. Having an email or phone number stored doesn't necessarily mean the contact information is actually verified or complete. That's definitely something I would tighten up as Loomwing moves beyond the current auth layer.
Thanks for pointing that out, I appreciate the observation.

Collapse
 
elijahbrown profile image
Elijah Brown •

That distinction is easy to lose once everything lives in one user record. Treating contact fields as their own state machine should keep auth success from silently becoming a delivery assumption.

Collapse
 
elijahbrown profile image
Elijah Brown •

That separation is the useful guardrail. Keeping contact completeness separate from authentication should make the later onboarding decisions much clearer.

Collapse
 
elijahbrown profile image
Elijah Brown •

That separation gives you a clean place to record verification state without letting it masquerade as identity data. I would keep the state explicit in the profile model and test the onboarding transitions around it.

Collapse
 
elijahbrown profile image
Elijah Brown •

Exactly. Keeping identity, profile completeness, and contact reachability as separate states makes the onboarding metrics much easier to trust.

Collapse
 
realcloudprojects profile image
SKILL.SCH •

Beautifully and well written. Welldone!

Collapse
 
anderson-devvs profile image
Anderson Chinedum •

Thanks, really appreciate it 😁🙏

Collapse
 
kyisaiah47 profile image
kyisaiah47 •

What does Loomwing do when Firebase creates the account but the Firestore profile write fails?

Collapse
 
anderson-devvs profile image
Anderson Chinedum •

Interesting question. In this current implementation, Firebase can successfully create the account while the Firestore profile write fails, which would leave an authenticated Firebase user without a corresponding Loomwing profile. The app already treats that missing profile as an incomplete application state, but I haven't implemented a full rollback flow for that signup failure yet. That's definitely one of the edge cases I need to tighten up.
Thanks for asking this.

Collapse
 
techenthu profile image
TechEnthu •

Building on the question above about the profile write failing: would a retry on next login be enough, or would you add something like a cloud function to reconcile it?