Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(auth): add corrent idp param to app gmail login bttns (#2207)
Seamusf9b79ae378c4
diff --git a/js/app/packages/app/component/auth/LoginOptions.tsx b/js/app/packages/app/component/auth/LoginOptions.tsxindex 7a54d51d5c..ec72f3b4cf 100644--- a/js/app/packages/app/component/auth/LoginOptions.tsx+++ b/js/app/packages/app/component/auth/LoginOptions.tsx@@ -10,10 +10,12 @@ import IconGoogle from '@macro-icons/macro-google.svg';import IconMail from '@macro-icons/macro-mail.svg';import { invalidateAllAfterLogin } from '@queries/auth/user-info';import { authServiceClient } from '@service-auth/client';+import { ROUTER_BASE_CONCAT } from '@app/constants/routerBase';import { useLocation } from '@solidjs/router';import { invoke } from '@tauri-apps/api/core';import { type JSX, Show } from 'solid-js';import { Stage } from './Shared';+import { GOOGLE_GMAIL_IDP } from '@core/auth/email';function LoginOption(props: {icon: JSX.Element;@@ -43,7 +45,10 @@ function LoginOption(props: {);}-export function LoginOptions(props: { setStage: (next: Stage) => void }) {+export function LoginOptions(props: {+ setStage: (next: Stage) => void;+ signupMode?: boolean;+}) {const location = useLocation<RedirectLocation>();const startSsoLogin = async (idp_name: string) => {@@ -122,11 +127,13 @@ export function LoginOptions(props: { setStage: (next: Stage) => void }) {<LoginOptionicon={<IconGoogle />}- label="Continue with Google"- onClick={() => startSsoLogin('google')}+ label={+ props.signupMode ? 'Sign up with Google' : 'Continue with Google'+ }+ onClick={() => startSsoLogin(GOOGLE_GMAIL_IDP)}/>- <Show when={!isNativeMobilePlatform()}>+ <Show when={!props.signupMode && !isNativeMobilePlatform()}><LoginOptionicon={<IconApple />}label="Continue with Apple"@@ -134,11 +141,24 @@ export function LoginOptions(props: { setStage: (next: Stage) => void }) {/></Show>- <LoginOption- icon={<IconMail />}- label="Continue with Email"- onClick={() => props.setStage(Stage.Email)}- />+ <Show when={!props.signupMode}>+ <LoginOption+ icon={<IconMail />}+ label="Continue with Email"+ onClick={() => props.setStage(Stage.Email)}+ />+ </Show>++ <Show when={props.signupMode}>+ <div class="p-4 text-center text-xs text-ink/50">+ <a+ class="underline hover:text-ink/70"+ href={`${ROUTER_BASE_CONCAT}login`}+ >+ Existing user? Log in+ </a>+ </div>+ </Show><div class="p-4 text-center text-xs text-ink/50">By signing up, you agree to ourdiff --git a/js/app/packages/app/component/auth/Signup.tsx b/js/app/packages/app/component/auth/Signup.tsxindex 863349447e..c43f08cfc8 100644--- a/js/app/packages/app/component/auth/Signup.tsx+++ b/js/app/packages/app/component/auth/Signup.tsx@@ -1,51 +1,51 @@-import { SERVER_HOSTS } from '@core/constant/servers';import { ClippedPanel } from '@core/component/ClippedPanel';+import { LoadingBlock } from '@core/component/LoadingBlock';import { PcNoiseGrid } from '@core/component/PcNoiseGrid';+import { toast } from '@core/component/Toast/Toast';+import { useEmailLinks } from '@core/email-link';import { useUserInfo } from '@queries/auth';-import { Navigate, useLocation } from '@solidjs/router';+import { useNavigate } from '@solidjs/router';import { onMount, Show } from 'solid-js';import { useAnalytics } from '@app/component/analytics-context';-import { ROUTER_BASE_CONCAT } from '@app/constants/routerBase';-import type { RedirectLocation } from '@core/util/authRedirect';-import IconGoogle from '@macro-icons/macro-google.svg';import LogoIcon from '@macro-icons/macro-logo.svg';+import { LoginOptions } from './LoginOptions';+import type { Stage } from './Shared';++function PostSignupRedirect() {+ const userInfo = useUserInfo();+ const navigate = useNavigate();+ const { initEmailLink } = useEmailLinks();++ onMount(async () => {+ await initEmailLink().match(+ () => {},+ (err) => {+ if (err.tag !== 'AlreadyInitialized') {+ toast.alert(+ 'Failed to connect email',+ 'Select email permissions on sign-in to enable'+ );+ }+ }+ );+ navigate(userInfo()?.tutorialComplete ? '/' : '/welcome', {+ replace: true,+ });+ });++ return <LoadingBlock />;+}export function Signup() {const userInfo = useUserInfo();const analytics = useAnalytics();- const location = useLocation<RedirectLocation>();onMount(() => {analytics.pageView('signup');});- const startGoogleLogin = () => {- const authUrl = new URL(`${SERVER_HOSTS['auth-service']}/login/sso`);- authUrl.searchParams.set('idp_name', 'google');-- const referral_code =- new URL(window.location.href).searchParams.get('referral_code') ??- new URLSearchParams(location.state?.originalLocation?.search).get(- 'referral_code'- );-- if (referral_code) authUrl.searchParams.set('referral_code', referral_code);-- authUrl.searchParams.set(- 'original_url',- `${window.location.origin}${ROUTER_BASE_CONCAT}welcome`- );-- window.location.href = authUrl.toString();- };-return (- <Show- when={!userInfo()?.authenticated}- fallback={- <Navigate href={userInfo()?.tutorialComplete ? '/' : '/welcome'} />- }- >+ <Show when={!userInfo()?.authenticated} fallback={<PostSignupRedirect />}><div class="flex items-center justify-center h-full w-full p-8 overflow-hidden relative"><style>{@@ -94,43 +94,11 @@ export function Signup() {Welcome to Macro</div><div class="px-8 pb-4 pt-2 text-center text-sm text-ink/60 leading-relaxed">- Sign in with Google to sync your inbox and set up your+ Sign up with Google to sync your inbox and set up yourworkspace.</div><div class="w-full">- <div class="grid select-none border-t border-edge-muted">- <div- onClick={startGoogleLogin}- class="grid items-center justify-center p-4 border-b border-edge-muted [transition:color_var(--transition)] hover:bg-hover/60 hover:text-accent hover:transition-none"- >- <div class="flex gap-2.5 items-center justify-center">- <IconGoogle />- <div class="whitespace-nowrap">Sign up with Google</div>- </div>- </div>-- <div class="p-4 text-center text-xs text-ink/50">- <a- class="underline hover:text-ink/70"- href={`${ROUTER_BASE_CONCAT}login`}- >- Existing user? Log in- </a>- </div>-- <div class="p-4 pt-0 text-center text-xs text-ink/50">- By signing up, you agree to our- <br />- <a class="underline hover:text-ink/70" href="/terms">- terms- </a>{' '}- and{' '}- <a class="underline hover:text-ink/70" href="/privacy">- privacy policy- </a>- .- </div>- </div>+ <LoginOptions signupMode setStage={(_stage: Stage) => {}} /></div></div></ClippedPanel>diff --git a/js/app/packages/app/component/interactive-onboarding/InteractiveOnboarding.tsx b/js/app/packages/app/component/interactive-onboarding/InteractiveOnboarding.tsxindex 524f34a497..c79ab8152f 100644--- a/js/app/packages/app/component/interactive-onboarding/InteractiveOnboarding.tsx+++ b/js/app/packages/app/component/interactive-onboarding/InteractiveOnboarding.tsx@@ -20,7 +20,11 @@ import { createOnboardingState } from './create-onboarding-state';import { LESSONS } from './lessons';import { ContinueButton, SkipButton } from './components-lib';import { OnboardingProgress } from './OnboardingProgress';-import { clearCompletedLessons, saveCompletedLesson } from './persistence';+import {+ clearCompletedLessons,+ loadCompletedLessons,+ saveCompletedLesson,+} from './persistence';import { ClippedPanel } from '@core/component/ClippedPanel';import { PcNoiseGrid } from '@core/component/PcNoiseGrid';import { useAnalytics } from '@app/component/analytics-context';@@ -59,7 +63,7 @@ export default function InteractiveOnboarding() {const state = createOnboardingState({definitions: lessons,- initialCompleted: debugCompleted ?? new Set(),+ initialCompleted: debugCompleted ?? loadCompletedLessons(),});const [readyToContinue, setReadyToContinue] = createSignal(false);@@ -75,9 +79,12 @@ export default function InteractiveOnboarding() {};// Redirect away if the backend already marks the tutorial as complete+ // before the user starts. We set tutorialComplete early (after the invite+ // step) so we track whether the flow has started to avoid a mid-flow redirect.+ const [onboardingStarted, setOnboardingStarted] = createSignal(false);const navigate = useNavigate();createEffect(() => {- if (tutorialCompleted() && !testMode) {+ if (tutorialCompleted() && !onboardingStarted() && !testMode) {if (splitPanel) {navigateAway();} else {@@ -104,6 +111,7 @@ export default function InteractiveOnboarding() {state: 'completed',});+ setOnboardingStarted(true);state.completeLesson(current.definition.id);if (!testMode) {saveCompletedLesson(current.definition.id);@@ -124,7 +132,11 @@ export default function InteractiveOnboarding() {state: 'skipped',});+ setOnboardingStarted(true);state.skipLesson(current.definition.id);+ if (!testMode) {+ saveCompletedLesson(current.definition.id);+ }setReadyToContinue(false);setContinueLabel(undefined);@@ -220,13 +232,23 @@ export default function InteractiveOnboarding() {}));+ // Mark tutorial complete on the backend once the email-invite lesson is+ // completed or skipped — before the paywall step.+ createEffect(() => {+ const invite = state+ .lessons()+ .find((l) => l.definition.id === 'email-invite');+ if (invite && (invite.completed || invite.skipped) && !testMode) {+ completeTutorial.mutate(undefined);+ }+ });+createEffect(on(() => state.isFinished(),(finished) => {if (finished && !testMode) {analytics.track('onboarding_completed');- completeTutorial.mutate(undefined);navigateAway();}}diff --git a/js/app/packages/core/auth/email.ts b/js/app/packages/core/auth/email.tsindex 886db9a38a..2ea9c84fc7 100644--- a/js/app/packages/core/auth/email.ts+++ b/js/app/packages/core/auth/email.ts@@ -1,7 +1,7 @@import { ROUTER_BASE } from '@app/constants/routerBase';import { SERVER_HOSTS } from '@core/constant/servers';-const GOOGLE_GMAIL_IDP = 'google_gmail';+export const GOOGLE_GMAIL_IDP = 'google_gmail';type IDPName = 'google_gmail';type EmailAuthParams = {