MCPcopy Create free account
hub / github.com/firebase/quickstart-js / onAuthChanged

Function onAuthChanged

database/scripts/main.ts:543–561  ·  view source on GitHub ↗

* Triggers every time there is a change in the Firebase auth state (i.e. user signed-in or user signed out).

(user: User | null)

Source from the content-addressed store, hash-verified

541 * Triggers every time there is a change in the Firebase auth state (i.e. user signed-in or user signed out).
542 */
543function onAuthChanged(user: User | null) {
544 // We ignore token refresh events.
545 if (user && currentUID === user.uid) {
546 return;
547 }
548
549 cleanupUi();
550 if (user) {
551 currentUID = user.uid;
552 splashPage.style.display = 'none';
553 writeUserData(user.uid, user.displayName, user.email, user.photoURL);
554 startDatabaseQueries();
555 } else {
556 // Set currentUID to null.
557 currentUID = null;
558 // Display the splash page where you can sign-in.
559 splashPage.style.display = '';
560 }
561}
562
563/**
564 * Creates a new post for the current user.

Callers

nothing calls this directly

Calls 3

cleanupUiFunction · 0.85
writeUserDataFunction · 0.85
startDatabaseQueriesFunction · 0.85

Tested by

no test coverage detected