Skip to content

Commit e2add3f

Browse files
RyukemeisterretrogtxDevanshusharma2005devin-ai-integration[bot]sean-brydon
authored
feat: enable microsoft sign ups (calcom#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 91ace14. * 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 <apk@cognition.ai> * refactor: revert pure formatting and import reordering changes Co-Authored-By: rajiv@cal.com <sahalrajiv6900@gmail.com> * 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 <apk@cognition.ai> * 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 <apk@cognition.ai> * chore: remove profileId related tests --------- Co-authored-by: amrit <iamamrit27@gmail.com> Co-authored-by: Devanshu Sharma <devanshusharma658@gmail.com> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Sean Brydon <sean@cal.com> Co-authored-by: bot_apk <apk@cognition.ai>
1 parent b7340f7 commit e2add3f

31 files changed

Lines changed: 2600 additions & 345 deletions

.env.example

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,17 @@ NEXT_PUBLIC_HELPSCOUT_KEY=
120120
NEXT_PUBLIC_FRESHCHAT_TOKEN=
121121
NEXT_PUBLIC_FRESHCHAT_HOST=
122122

123+
# Microsoft OAuth credentials
124+
OUTLOOK_LOGIN_ENABLED=false
125+
126+
123127
# For holiday feature:
124128
# Step-by-step: Get a Google Calendar API Key
125129
# 1. Go to Google Cloud Console: https://console.cloud.google.com/
126130
# 2. Select or Create a Project
127131
# 3. Enable Google Calendar API (APIs & Services → Library , Search for Google Calendar API)
128132
# 4. Create the API Key (APIs & Services → Credentials)
129133
GOOGLE_CALENDAR_API_KEY=
130-
131134
# Google OAuth credentials
132135
# To enable Login with Google you need to:
133136
# 1. Set `GOOGLE_API_CREDENTIALS` below

apps/web/lib/signup/getServerSideProps.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { GetServerSidePropsContext } from "next";
22
import { z } from "zod";
33

44
import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
5+
import { IS_OUTLOOK_LOGIN_ENABLED } from "@calcom/features/auth/lib/outlook";
56
import { getOrgUsernameFromEmail } from "@calcom/features/auth/signup/utils/getOrgUsernameFromEmail";
67
import { checkPremiumUsername } from "@calcom/features/ee/common/lib/checkPremiumUsername";
78
import { isSAMLLoginEnabled } from "@calcom/features/ee/sso/lib/saml";
@@ -59,6 +60,7 @@ export const getServerSideProps = async (ctx: GetServerSidePropsContext) => {
5960
const props = {
6061
redirectUrl,
6162
isGoogleLoginEnabled: IS_GOOGLE_LOGIN_ENABLED,
63+
isOutlookLoginEnabled: IS_OUTLOOK_LOGIN_ENABLED,
6264
isSAMLLoginEnabled,
6365
prepopulateFormValues: undefined,
6466
emailVerificationEnabled,

apps/web/modules/auth/hooks/useLastUsed.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useLocale } from "@calcom/lib/hooks/useLocale";
44
import { localStorage } from "@calcom/lib/webstorage";
55
import classNames from "@calcom/ui/classNames";
66

7-
type LoginType = "saml" | "google" | "credentials";
7+
type LoginType = "saml" | "google" | "microsoft" | "credentials";
88

99
export function useLastUsed() {
1010
const [lastUsed, setLastUsed] = useState<LoginType>();

0 commit comments

Comments
 (0)