MCPcopy Index your code
hub / github.com/monkeytypegame/monkeytype / onAuthStateChanged

Function onAuthStateChanged

frontend/src/ts/auth.tsx:170–197  ·  view source on GitHub ↗
(
  authInitialisedAndConnected: boolean,
  user: UserType | null,
)

Source from the content-addressed store, hash-verified

168}
169
170export async function onAuthStateChanged(
171 authInitialisedAndConnected: boolean,
172 user: UserType | null,
173): Promise<void> {
174 console.debug(`account controller ready`);
175
176 let userPromise: Promise<void> = Promise.resolve();
177
178 if (authInitialisedAndConnected) {
179 console.debug(`auth state changed, user ${user ? "true" : "false"}`);
180 if (user) {
181 setUserId(user.uid);
182 userPromise = loadUser(user);
183 } else {
184 setUserId(null);
185 DB.setSnapshot(undefined);
186 }
187 }
188
189 if (!authInitialisedAndConnected || !user) {
190 void Sentry.clearUser();
191 }
192
193 authEvent.dispatch({
194 type: "authStateChanged",
195 data: { isUserSignedIn: user !== null, loadPromise: userPromise },
196 });
197}
198
199export async function signIn(
200 email: string,

Callers 2

initFunction · 0.90
signUpFunction · 0.85

Calls 2

loadUserFunction · 0.85
dispatchMethod · 0.80

Tested by

no test coverage detected