Skip to content

How to properly delay a guard until angular knows the definitive session state #3656

Open
@franjorub

Description

@franjorub

Angular 19

Hi, I have been playing around learning how to protect some routes with authentication

my problem is that the user state takes a moment to properly notify the final resolution

meaning that, if a user is authenticated and access to a protected route, the user state returns null and then the user, breaking the protection

I have been trying different techniques like BehaviorSubject<User | null | undefined> and filtering the undefined state to know that firebase still didn't provide a final state

I have also found a guy getting the session from the cookies https://medium.com/@ignatovich.dm/securing-angular-applications-with-route-guards-and-firebase-auth-54c02bdd4811 it is sync and with a straight answer

if I could find some examples for these use cases I will appreciate !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions