diff --git a/gui/src/components/OnboardingCard/platform/tabs/main.tsx b/gui/src/components/OnboardingCard/platform/tabs/main.tsx index 4295dd18d..f6a14cb93 100644 --- a/gui/src/components/OnboardingCard/platform/tabs/main.tsx +++ b/gui/src/components/OnboardingCard/platform/tabs/main.tsx @@ -13,8 +13,11 @@ export default function MainTab({ const auth = useAuth(); function onGetStarted() { - auth.login(true); - onboardingCard.close(); + auth.login(true).then((success) => { + if (success) { + onboardingCard.close(); + } + }); } return ( diff --git a/gui/src/context/Auth.tsx b/gui/src/context/Auth.tsx index df6cf8ed7..361ee8e0c 100644 --- a/gui/src/context/Auth.tsx +++ b/gui/src/context/Auth.tsx @@ -24,7 +24,7 @@ import { IdeMessengerContext } from "./IdeMessenger"; interface AuthContextType { session: ControlPlaneSessionInfo | undefined; logout: () => void; - login: (useOnboarding: boolean) => void; + login: (useOnboarding: boolean) => Promise; selectedProfile: ProfileDescription | undefined; profiles: ProfileDescription[]; controlServerBetaEnabled: boolean; @@ -55,36 +55,42 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ (state) => state.misc.lastControlServerBetaEnabledStatus, ); - const login = (useOnboarding: boolean) => { - ideMessenger - .request("getControlPlaneSessionInfo", { - silent: false, - useOnboarding, - }) - .then((result) => { - if (result.status === "error") { - return; - } - const session = result.content; - setSession(session); + const login: AuthContextType["login"] = (useOnboarding: boolean) => { + return new Promise((resolve) => { + ideMessenger + .request("getControlPlaneSessionInfo", { + silent: false, + useOnboarding, + }) + .then((result) => { + if (result.status === "error") { + resolve(false); + return; + } - // If this is the first time the user has logged in, explain how profiles work - if (!getLocalStorage("shownProfilesIntroduction")) { - dispatch(setShowDialog(true)); - dispatch( - setDialogMessage( - {}} - />, - ), - ); - setLocalStorage("shownProfilesIntroduction", true); - } - }); + const session = result.content; + setSession(session); + + // If this is the first time the user has logged in, explain how profiles work + if (!getLocalStorage("shownProfilesIntroduction")) { + dispatch(setShowDialog(true)); + dispatch( + setDialogMessage( + {}} + />, + ), + ); + setLocalStorage("shownProfilesIntroduction", true); + } + + resolve(true); + }); + }); }; const logout = () => {