diff --git a/frontend/src/ts/firebase.ts b/frontend/src/ts/firebase.ts index 7aff3b0624fd..55462c8bc268 100644 --- a/frontend/src/ts/firebase.ts +++ b/frontend/src/ts/firebase.ts @@ -134,7 +134,7 @@ export async function signInWithEmailAndPassword( return result; } -function setUserState( +export function setUserState( options: { uid: string; emailVerified: boolean; @@ -166,10 +166,10 @@ export async function signInWithPopup( throw translateFirebaseError(error, "Failed to sign in with popup"); } const additionalUserInfo = getAdditionalUserInfo(signedInUser); - setUserState(signedInUser.user); if (additionalUserInfo?.isNewUser) { googleSignUpEvent.dispatch({ signedInUser, isNewUser: true }); } else { + setUserState(signedInUser.user); ignoreAuthCallback = false; await readyCallback?.(true, signedInUser.user); } diff --git a/frontend/src/ts/modals/google-sign-up.ts b/frontend/src/ts/modals/google-sign-up.ts index 8f6305d0438f..63ab9b4686b4 100644 --- a/frontend/src/ts/modals/google-sign-up.ts +++ b/frontend/src/ts/modals/google-sign-up.ts @@ -17,7 +17,7 @@ import * as CaptchaController from "../controllers/captcha-controller"; import { showLoaderBar, hideLoaderBar } from "../states/loader-bar"; import { googleSignUpEvent } from "../events/google-sign-up"; import AnimatedModal from "../utils/animated-modal"; -import { resetIgnoreAuthCallback } from "../firebase"; +import { resetIgnoreAuthCallback, setUserState } from "../firebase"; import { ValidatedHtmlInputElement } from "../elements/input-validation"; import { UserNameSchema } from "@monkeytype/schemas/users"; import { remoteValidation } from "../utils/remote-validation"; @@ -105,6 +105,7 @@ async function apply(): Promise { } if (response.status === 200) { + setUserState(signedInUser.user); await updateProfile(signedInUser.user, { displayName: name }); await sendEmailVerification(signedInUser.user); showSuccessNotification("Account created");