feat: enable microsoft sign ups (#28080)

* fix: trigger lingo.dev by removing duplicate value

* under progress

* wow this worked

* migrate schema

* fix types

* fix import for google login

* Add onboarding tests for Azure (Microsoft sign up)

* add comments back

* fix failing test

* fix: update Outlook login configuration and improve type safety in authentication adapter

- Set OUTLOOK_LOGIN_ENABLED to false in .env.example
- Refactor getServerSideProps to directly use samlTenantID and samlProductID
- Update linkAccount method in next-auth-custom-adapter for better type handling
- Remove redundant comment in next-auth-options related to Azure AD email verification

* remove log

* remove debug log from signin callback in next-auth options

* fixup

* chore: standardize naming

* chore: add primary calendar for outlook, verify email and auto link org for outlook

* chore: helper fns

* chore: implement cubic feedback

* cleanup

* chore: implement cubic feedback again

* WIP design#

* feat: login design

* fix: map identity provider names correctly

* 32px of mt

* fix: login UI

* fix: type check

* fix: fix type check again

* chore: update OAuth login tests

* fixup

* fix: bad import

* chore: update tests

* fixup

* fix: locales test

* chore: implement PR feedback and fix minor issues

* fix: revert token spreading change

* fix: merge conflicts

* chore: revert signup view changes

* fixup: bring back reverted changes because of merge conflicts

* fix: disable email input when microsoft sign in is in progress

* chore: implement cubic feedback

* cleanup: unused variables

* fix: address Cubic AI review feedback (confidence >= 9/10)

- Remove userId (PII) from log payloads in updateProfilePhotoMicrosoft.ts
- Replace text selectors with data-testid in locale.e2e.ts and oauth-provider.e2e.ts
- Restore callbackUrl redirect parameter in signup link in login-view.tsx
- Add data-testid='login-subtitle' to login page subtitle element

Co-Authored-By: unknown <>

* fix: use empty alt for decorative icon images in login view

MicrosoftIcon and GoogleIcon are decorative (adjacent to text labels),
so they should have empty alt attributes per accessibility best practices.

Co-Authored-By: unknown <>

* chore: implement cubic feedback

* cleanup

* fixup

* chore: implement PR feedback

* chore: implement feedback

* fix: address PR review feedback - type safety and centralize constants

- Replace non-null assertions (!) with proper null checks for OUTLOOK_CLIENT_ID/SECRET
- Replace `as any` casting with `Record<string, unknown>` for OAuth profile claims
- Remove non-null assertion on account.access_token by adding conditional check
- Centralize Outlook env constants in @calcom/lib/constants alongside MICROSOFT_CALENDAR_SCOPES
- Add explanatory comment for getNextAuthProviderName usage in get.handler.ts

Co-Authored-By: unknown <>

* Revert "fix: address PR review feedback - type safety and centralize constants"

This reverts commit 91ace141e6a28a23deea5897f7f9d6ad80319d84.

* chore: implement feedback

* chore: cleanup

* chore: implement feedback

* fix: merge conflicts

* fix: revert formatting-only changes in packages/lib/constants.ts

Co-Authored-By: unknown <>

* fix: revert IdentityProvider enum location change in schema.prisma

Co-Authored-By: unknown <>

* chore: implement more PR feedback

* fix: restore database-derived profileId from determineProfile in OAuth JWT

The profileId regression was identified by Cubic AI (confidence 9/10).

Previously, determineProfile's returned id was used to set profileId in the
JWT via 'profileResult.id ?? token.profileId ?? null'. A recent refactor
changed this to 'token.profileId ?? null', which drops the database-derived
profile ID. On first OAuth login (or when profile switcher is disabled),
token.profileId is likely null, so profileId would incorrectly be set to
null even though determineProfile returned a valid profile with an id.

This commit restores the correct priority chain:
  visitorProfileId ?? token.profileId ?? null

Co-Authored-By: bot_apk <[email protected]>

* refactor: revert pure formatting and import reordering changes

Co-Authored-By: [email protected] <[email protected]>

* fix: normalize determineProfile return type to use consistent 'id' field

The determineProfile function returned a union type where one branch used
'id' and the other used 'profileId'. This caused TS2339 when destructuring
'id' from the result. Normalize the token.upId branch to also return 'id'
(mapped from token.profileId) so the return type is consistent.

Co-Authored-By: bot_apk <[email protected]>

* chore: add tests

* reveret: profileId changes should be in a separate PR

* fix: avoid logging entire existingUser object in OAuth JWT callback

Revert to logging only { userId, upId } instead of the full existingUser
object, which contains PII (email, name, identity provider details).
This restores the previous safe logging pattern.

Co-Authored-By: bot_apk <[email protected]>

* chore: remove profileId related tests

---------

Co-authored-by: amrit <[email protected]>
Co-authored-by: Devanshu Sharma <[email protected]>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Sean Brydon <[email protected]>
Co-authored-by: bot_apk <[email protected]>
This commit is contained in:
authored and GitHub committed 2026-03-05 16:47:40 +05:30
1 parent b7340f7151
commit e2add3f2c9
31 files changed
+2602 -347

No files matched your search

+1 -1
View File
@@ -4,7 +4,7 @@ import { useLocale } from "@calcom/lib/hooks/useLocale";
import { localStorage } from "@calcom/lib/webstorage";
import classNames from "@calcom/ui/classNames";
type LoginType = "saml" | "google" | "credentials";
type LoginType = "saml" | "google" | "microsoft" | "credentials";
export function useLastUsed() {
const [lastUsed, setLastUsed] = useState<LoginType>();
+308 -183
View File
@@ -1,17 +1,6 @@
"use client";
import { zodResolver } from "@hookform/resolvers/zod";
import classNames from "classnames";
import { signIn } from "next-auth/react";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { useEffect, useState } from "react";
import { FormProvider, useForm } from "react-hook-form";
import { z } from "zod";
import { SAMLLogin } from "@calcom/web/modules/auth/components/SAMLLogin";
import { ErrorCode } from "@calcom/features/auth/lib/ErrorCode";
import { LastUsed, useLastUsed } from "@calcom/web/modules/auth/hooks/useLastUsed";
import { HOSTED_CAL_FEATURES, WEBAPP_URL, WEBSITE_URL } from "@calcom/lib/constants";
import { emailRegex } from "@calcom/lib/emailSchema";
import { getSafeRedirectUrl } from "@calcom/lib/getSafeRedirectUrl";
@@ -19,17 +8,27 @@ import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
import { Alert } from "@calcom/ui/components/alert";
import { Button } from "@calcom/ui/components/button";
import { EmailField, PasswordField } from "@calcom/ui/components/form";
import type { inferSSRProps } from "@lib/types/inferSSRProps";
import { Icon } from "@calcom/ui/components/icon";
import { SAMLLogin } from "@calcom/web/modules/auth/components/SAMLLogin";
import { LastUsed, useLastUsed } from "@calcom/web/modules/auth/hooks/useLastUsed";
import AddToHomescreen from "@components/AddToHomescreen";
import BackupCode from "@components/auth/BackupCode";
import TwoFactor from "@components/auth/TwoFactor";
import AuthContainer from "@components/ui/AuthContainer";
import { Button } from "@coss/ui/components/button";
import { Field, FieldLabel } from "@coss/ui/components/field";
import { Input } from "@coss/ui/components/input";
import { InputGroup, InputGroupAddon, InputGroupInput } from "@coss/ui/components/input-group";
import { Separator } from "@coss/ui/components/separator";
import { zodResolver } from "@hookform/resolvers/zod";
import type { inferSSRProps } from "@lib/types/inferSSRProps";
import type { getServerSideProps } from "@server/lib/auth/login/getServerSideProps";
import { Eye, EyeOff } from "lucide-react";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { signIn } from "next-auth/react";
import { useEffect, useState } from "react";
import { FormProvider, useForm } from "react-hook-form";
import { z } from "zod";
interface LoginValues {
email: string;
@@ -39,13 +38,75 @@ interface LoginValues {
csrfToken: string;
}
const GoogleIcon = () => (
<img className="mr-2 w-4 h-4 text-subtle" src="/google-icon-colored.svg" alt="Continue with Google Icon" />
const MicrosoftIcon = () => (
<img className="size-4" src="/microsoft-logo.svg" alt="" />
);
const GoogleIcon = () => (
<img className="size-4" src="/google-icon-colored.svg" alt="" />
);
function BackgroundGrid() {
const rows = 9;
const cols = 18;
const size = 60;
const gap = 8;
const radius = 8;
const width = cols * size + (cols - 1) * gap;
const height = rows * size + (rows - 1) * gap;
return (
<div className="pointer-events-none absolute inset-0 flex items-center justify-center overflow-hidden">
<svg
width={width}
height={height}
viewBox={`0 0 ${width} ${height}`}
fill="none"
className="[--grid-fill:#f7f7f7] [--grid-stroke:rgba(34,42,53,0.08)] dark:[--grid-fill:#1f1f1f] dark:[--grid-stroke:rgba(255,255,255,0.08)]">
<defs>
<radialGradient id="gridFade" cx="50%" cy="50%" rx="70%" ry="70%">
<stop offset="20%" stopColor="white" stopOpacity="1" />
<stop offset="100%" stopColor="white" stopOpacity="0" />
</radialGradient>
<mask id="gridMask">
<rect width={width} height={height} fill="url(#gridFade)" />
</mask>
<filter id="gridShadow" x="-20%" y="-20%" width="140%" height="140%">
<feDropShadow dx="0" dy="4" stdDeviation="4" floodColor="rgba(34,42,53,0.05)" />
<feDropShadow dx="0" dy="1" stdDeviation="2" floodColor="rgba(19,19,22,0.03)" />
</filter>
</defs>
<g mask="url(#gridMask)">
{Array.from({ length: rows * cols }).map((_, i) => {
const col = i % cols;
const row = Math.floor(i / cols);
const x = col * (size + gap);
const y = row * (size + gap);
return (
<rect
key={i}
x={x}
y={y}
width={size}
height={size}
rx={radius}
fill="var(--grid-fill)"
stroke="var(--grid-stroke)"
strokeWidth="1"
filter="url(#gridShadow)"
/>
);
})}
</g>
</svg>
</div>
);
}
export type PageProps = inferSSRProps<typeof getServerSideProps>;
export default function Login({
csrfToken,
isGoogleLoginEnabled,
isOutlookLoginEnabled,
isSAMLLoginEnabled,
samlTenantID,
samlProductID,
@@ -70,6 +131,7 @@ export default function Login({
const [twoFactorLostAccess, setTwoFactorLostAccess] = useState(false);
const [errorMessage, setErrorMessage] = useState<string | null>(null);
const [lastUsed, setLastUsed] = useLastUsed();
const [showPassword, setShowPassword] = useState(false);
const errorMessages: { [key: string]: string } = {
// [ErrorCode.SecondFactorRequired]: t("2fa_enabled_instructions"),
@@ -93,57 +155,20 @@ export default function Login({
callbackUrl = safeCallbackUrl || "";
const signupUrl = callbackUrl
? `${WEBSITE_URL}/signup?redirect=${encodeURIComponent(callbackUrl)}`
: `${WEBSITE_URL}/signup`;
const { data, isPending, error } = trpc.viewer.public.ssoConnections.useQuery();
const LoginFooter = (
<Link href={signupUrl} className="font-medium text-brand-500">
{t("dont_have_an_account")}
</Link>
useEffect(
function refactorMeWithoutEffect() {
if (error) {
setErrorMessage(error.message);
}
},
[error]
);
const TwoFactorFooter = (
<>
<Button
onClick={() => {
if (twoFactorLostAccess) {
setTwoFactorLostAccess(false);
methods.setValue("backupCode", "");
} else {
setTwoFactorRequired(false);
methods.setValue("totpCode", "");
}
setErrorMessage(null);
}}
StartIcon="arrow-left"
color="minimal">
{t("go_back")}
</Button>
{!twoFactorLostAccess ? (
<Button
onClick={() => {
setTwoFactorLostAccess(true);
setErrorMessage(null);
methods.setValue("totpCode", "");
}}
StartIcon="lock"
color="minimal">
{t("lost_access")}
</Button>
) : null}
</>
);
const ExternalTotpFooter = (
<Button
onClick={() => {
window.location.replace("/");
}}
color="minimal">
{t("cancel")}
</Button>
);
const displaySSOLogin = HOSTED_CAL_FEATURES
? true
: isSAMLLoginEnabled && !isPending && data?.connectionExists;
const onSubmit = async (values: LoginValues) => {
setErrorMessage(null);
@@ -165,132 +190,232 @@ export default function Login({
else setErrorMessage(errorMessages[res.error] || t("something_went_wrong"));
};
const { data, isPending, error } = trpc.viewer.public.ssoConnections.useQuery();
useEffect(
function refactorMeWithoutEffect() {
if (error) {
setErrorMessage(error.message);
}
},
[error]
);
const displaySSOLogin = HOSTED_CAL_FEATURES
? true
: isSAMLLoginEnabled && !isPending && data?.connectionExists;
const showSocialLogin = isGoogleLoginEnabled || isOutlookLoginEnabled;
const showSignupLink =
process.env.NEXT_PUBLIC_DISABLE_SIGNUP !== "true" && searchParams?.get("register") !== "false";
return (
<div className="text-emphasis min-h-screen [--cal-brand-emphasis:#101010] [--cal-brand-subtle:#9CA3AF] [--cal-brand-text:white] [--cal-brand:#111827] dark:[--cal-brand-emphasis:#e1e1e1] dark:[--cal-brand-text:black] dark:[--cal-brand:white]">
<AuthContainer
showLogo
heading={twoFactorRequired ? t("2fa_code") : t("welcome_back")}
footerText={
twoFactorRequired
? !totpEmail
? TwoFactorFooter
: ExternalTotpFooter
: process.env.NEXT_PUBLIC_DISABLE_SIGNUP !== "true" && searchParams?.get("register") !== "false"
? LoginFooter
: null
}>
<FormProvider {...methods}>
{!twoFactorRequired && (
<>
<div className="stack-y-3">
{isGoogleLoginEnabled && (
<Button
color="primary"
className="justify-center w-full"
disabled={formState.isSubmitting}
data-testid="google"
CustomStartIcon={<GoogleIcon />}
onClick={async (e) => {
e.preventDefault();
setLastUsed("google");
await signIn("google", {
callbackUrl,
});
}}>
<span>{t("signin_with_google")}</span>
{lastUsed === "google" && <LastUsed />}
</Button>
)}
{displaySSOLogin && (
<SAMLLogin
disabled={formState.isSubmitting}
samlTenantID={samlTenantID}
samlProductID={samlProductID}
setErrorMessage={setErrorMessage}
/>
)}
</div>
{(isGoogleLoginEnabled || displaySSOLogin) && (
<div className="my-8">
<div className="flex relative items-center">
<div className="border-t border-subtle grow" />
<span className="mx-2 text-sm font-normal leading-none text-subtle shrink">
{t("or").toLocaleLowerCase()}
</span>
<div className="border-t border-subtle grow" />
</div>
<div className="relative flex min-h-screen items-center justify-center bg-default/80 px-4 py-10">
<BackgroundGrid />
<div className="relative z-10 flex w-full max-w-md flex-col items-center">
{/* Main Card */}
<div className="w-full rounded-xl border border-subtle bg-default p-10 shadow-sm">
{/* Logo */}
<div className="mb-2 text-center">
<h1 className="font-cal text-xl font-bold text-emphasis">Cal.com</h1>
</div>
{/* Heading */}
<p className="mb-8 text-center text-sm text-subtle" data-testid="login-subtitle">
{twoFactorRequired ? t("2fa_code") : t("welcome_back_sign_in")}
</p>
<FormProvider {...methods}>
{/* Social Login Buttons */}
{!twoFactorRequired && showSocialLogin && (
<>
<div className="flex flex-col gap-2">
{isGoogleLoginEnabled && (
<Button
className="w-full"
disabled={formState.isSubmitting}
data-testid="google"
onClick={async (e) => {
e.preventDefault();
setLastUsed("google");
await signIn("google", {
callbackUrl,
});
}}>
<GoogleIcon />
<span>{t("signin_with_google")}</span>
{lastUsed === "google" && <LastUsed />}
</Button>
)}
{isOutlookLoginEnabled && (
<Button
variant="outline"
className="w-full"
data-testid="microsoft"
onClick={async (e) => {
e.preventDefault();
setLastUsed("microsoft");
await signIn("azure-ad", {
callbackUrl,
});
}}>
<MicrosoftIcon />
<span>{t("signin_with_microsoft")}</span>
{lastUsed === "microsoft" && <LastUsed />}
</Button>
)}
</div>
{/* Divider */}
<div className="my-6 flex items-center gap-4">
<Separator className="flex-1" />
<span className="text-sm text-zinc-400">{t("or").toLowerCase()}</span>
<Separator className="flex-1" />
</div>
</>
)}
<form onSubmit={methods.handleSubmit(onSubmit)} noValidate data-testid="login-form">
<input defaultValue={csrfToken || undefined} type="hidden" hidden {...register("csrfToken")} />
{!twoFactorRequired && (
<div className="space-y-6">
{/* Email Field */}
<Field>
<FieldLabel>{t("email")}</FieldLabel>
<Input
id="email"
type="email"
defaultValue={totpEmail || (searchParams?.get("email") as string)}
autoComplete="email"
{...register("email")}
/>
{formState.errors.email && (
<p data-testid="field-error" className="text-destructive-foreground text-xs">
{formState.errors.email.message}
</p>
)}
</Field>
{/* Password Field */}
<Field>
<div className="flex w-full items-center justify-between">
<FieldLabel>{t("password")}</FieldLabel>
<Link href="/auth/forgot-password" className="text-sm text-subtle hover:text-emphasis">
{t("forgot")}
</Link>
</div>
<InputGroup className="overflow-hidden">
<InputGroupInput
id="password"
type={showPassword ? "text" : "password"}
autoComplete="current-password"
{...register("password")}
/>
<InputGroupAddon align="inline-end">
<Button
type="button"
variant="ghost"
size="icon-xs"
onClick={() => setShowPassword(!showPassword)}
aria-label={showPassword ? t("hide_password") : t("show_password")}>
{showPassword ? <EyeOff className="size-4" /> : <Eye className="size-4" />}
</Button>
</InputGroupAddon>
</InputGroup>
{formState.errors.password && (
<p data-testid="field-error" className="text-destructive-foreground text-xs">
{formState.errors.password.message}
</p>
)}
</Field>
</div>
)}
</>
)}
<form onSubmit={methods.handleSubmit(onSubmit)} noValidate data-testid="login-form">
<div>
<input defaultValue={csrfToken || undefined} type="hidden" hidden {...register("csrfToken")} />
</div>
<div className="stack-y-6">
<div
className={classNames("stack-y-6", {
hidden: twoFactorRequired,
})}>
<EmailField
id="email"
label={t("email_address")}
defaultValue={totpEmail || (searchParams?.get("email") as string)}
placeholder="[email protected]"
required
autoComplete="email"
{...register("email")}
/>
<div className="relative">
<PasswordField
id="password"
autoComplete="current-password"
required={!totpEmail}
className="mb-0"
{...register("password")}
/>
<div className="absolute -top-[2px] ltr:right-0 rtl:left-0">
<Link
href="/auth/forgot-password"
tabIndex={-1}
className="text-sm font-medium text-default">
{t("forgot")}
</Link>
</div>
{/* Two Factor */}
{twoFactorRequired && (
<div className="space-y-4">
{!twoFactorLostAccess ? <TwoFactor center /> : <BackupCode center />}
</div>
</div>
)}
{twoFactorRequired ? !twoFactorLostAccess ? <TwoFactor center /> : <BackupCode center /> : null}
{/* Error Message */}
{errorMessage && <Alert severity="error" title={errorMessage} className="mt-4" />}
{errorMessage && <Alert severity="error" title={errorMessage} />}
{/* Submit Button */}
<Button
type="submit"
color="secondary"
disabled={formState.isSubmitting}
className="justify-center w-full">
<span>{twoFactorRequired ? t("submit") : t("sign_in")}</span>
{lastUsed === "credentials" && !twoFactorRequired && <LastUsed className="text-gray-600" />}
variant="outline"
className="mt-8 w-full"
disabled={formState.isSubmitting}>
{twoFactorRequired ? t("submit") : t("continue")}
</Button>
</div>
</form>
</FormProvider>
</AuthContainer>
</form>
{/* Two Factor Footer */}
{twoFactorRequired && (
<div className="mt-4 flex justify-center gap-4">
{!totpEmail ? (
<>
<Button
variant="ghost"
onClick={() => {
if (twoFactorLostAccess) {
setTwoFactorLostAccess(false);
methods.setValue("backupCode", "");
} else {
setTwoFactorRequired(false);
methods.setValue("totpCode", "");
}
setErrorMessage(null);
}}>
<Icon name="arrow-left" className="mr-2 size-4" />
{t("go_back")}
</Button>
{!twoFactorLostAccess && (
<Button
variant="ghost"
onClick={() => {
setTwoFactorLostAccess(true);
setErrorMessage(null);
methods.setValue("totpCode", "");
}}>
<Icon name="lock" className="mr-2 size-4" />
{t("lost_access")}
</Button>
)}
</>
) : (
<Button
variant="ghost"
onClick={() => {
window.location.replace("/");
}}>
{t("cancel")}
</Button>
)}
</div>
)}
</FormProvider>
</div>
{/* Footer Links */}
{!twoFactorRequired && (
<div className="mt-6 flex items-center justify-center gap-4 text-center">
{showSignupLink && (
<Link
href={
callbackUrl
? `${WEBSITE_URL}/signup?redirect=${encodeURIComponent(callbackUrl)}`
: `${WEBSITE_URL}/signup`
}
className="text-sm font-medium text-emphasis hover:underline">
{t("create_account")}
</Link>
)}
{displaySSOLogin && (
<>
{showSignupLink && <span className="text-subtle">·</span>}
<SAMLLogin
samlTenantID={samlTenantID}
samlProductID={samlProductID}
setErrorMessage={setErrorMessage}
color="minimal"
StartIcon={undefined}
className="text-sm font-medium text-emphasis hover:underline p-0 h-auto"
/>
</>
)}
</div>
)}
</div>
<AddToHomescreen />
</div>
);
@@ -32,6 +32,8 @@ export default function Provider(props: SSOProviderPageProps) {
signIn("saml", {}, { tenant: props.tenant, product: props.product });
} else if (props.provider === "google" && email) {
signIn("google", {}, { login_hint: email });
} else if (props.provider === "microsoft") {
signIn("azure-ad");
} else {
signIn(props.provider);
}
+59 -4
View File
@@ -187,6 +187,7 @@ export default function Signup({
token,
orgSlug,
isGoogleLoginEnabled,
isOutlookLoginEnabled,
isSAMLLoginEnabled,
orgAutoAcceptEmail,
redirectUrl,
@@ -198,6 +199,7 @@ export default function Signup({
const [premiumUsername, setPremiumUsername] = useState(false);
const [usernameTaken, setUsernameTaken] = useState(false);
const [isGoogleLoading, setIsGoogleLoading] = useState(false);
const [isMicrosoftLoading, setIsMicrosoftLoading] = useState(false);
const [accountUnderReview, setAccountUnderReview] = useState(false);
const [displayEmailForm, setDisplayEmailForm] = useState(token);
const [turnstileKey, setTurnstileKey] = useState(0);
@@ -652,6 +654,7 @@ export default function Signup({
<Button
color="primary"
loading={isGoogleLoading}
disabled={isMicrosoftLoading}
CustomStartIcon={
<>
{/* eslint-disable @next/next/no-img-element */}
@@ -684,8 +687,8 @@ export default function Signup({
searchQueryParams.set("username", prepopulateFormValues.username);
localStorage.setItem("username", prepopulateFormValues.username);
}
if (token) {
searchQueryParams.set("email", prepopulateFormValues?.email);
if (token && prepopulateFormValues?.email) {
searchQueryParams.set("email", prepopulateFormValues.email);
}
const url = searchQueryParams.toString()
? `${GOOGLE_AUTH_URL}?${searchQueryParams.toString()}`
@@ -698,7 +701,59 @@ export default function Signup({
</div>
)}
{isGoogleLoginEnabled && (
{isOutlookLoginEnabled && (
<div className="flex flex-col gap-2 md:flex-row">
<Button
color="secondary"
loading={isMicrosoftLoading}
disabled={isGoogleLoading}
CustomStartIcon={
<>
{/* eslint-disable @next/next/no-img-element */}
<img
className={classNames(
"text-subtle mr-2 h-4 w-4",
premiumUsername && "opacity-50"
)}
src="/microsoft-logo.svg"
alt="Continue with Microsoft Icon"
/>
</>
}
className={classNames("w-full justify-center rounded-md text-center")}
data-testid="continue-with-microsoft-button"
onClick={async () => {
posthog.capture("signup_microsoft_button_clicked", {
has_token: !!token,
is_org_invite: isOrgInviteByLink,
org_slug: orgSlug,
has_prepopulated_username: !!prepopulateFormValues?.username,
});
setIsSamlSignup(false);
setIsMicrosoftLoading(true);
const baseUrl = process.env.NEXT_PUBLIC_WEBAPP_URL;
const MICROSOFT_AUTH_URL = `${baseUrl}/auth/sso/microsoft`;
const searchQueryParams = new URLSearchParams();
if (prepopulateFormValues?.username) {
// If username is present we save it in query params to check for premium
searchQueryParams.set("username", prepopulateFormValues.username);
localStorage.setItem("username", prepopulateFormValues.username);
}
if (token && prepopulateFormValues?.email) {
searchQueryParams.set("email", prepopulateFormValues.email);
}
const url = searchQueryParams.toString()
? `${MICROSOFT_AUTH_URL}?${searchQueryParams.toString()}`
: MICROSOFT_AUTH_URL;
router.push(url);
}}>
{t("continue_with_microsoft")}
</Button>
</div>
)}
{(isGoogleLoginEnabled || isOutlookLoginEnabled) && (
<div>
<div className="relative flex items-center">
<div className="border-subtle grow border-t" />
@@ -714,7 +769,7 @@ export default function Signup({
<div className="flex flex-col gap-2">
<Button
color="secondary"
disabled={isGoogleLoading}
disabled={isGoogleLoading || isMicrosoftLoading}
className={classNames("w-full justify-center rounded-md text-center")}
onClick={() => {
posthog.capture("signup_email_button_clicked", {