Conversation
…thentication 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
Resolved conflicts in: - .env.example: Kept both Microsoft OAuth and Google Calendar API Key sections - apps/web/lib/signup/getServerSideProps.tsx: Kept both getServerSession and IS_OUTLOOK_LOGIN_ENABLED imports - apps/web/modules/signup-view.tsx: Merged Microsoft auth with upstream's posthog tracking - packages/features/auth/lib/identityProviderNameMap.ts: Deleted (removed in upstream) - packages/features/auth/lib/next-auth-custom-adapter.ts: Used upstream's refactored helper functions - packages/features/auth/lib/next-auth-options.ts: Merged Microsoft auth with upstream's billing service integration - turbo.json: Added AZURE_AD_TENANT_ID, removed APP_USER_NAME per upstream Co-Authored-By: unknown <>
Co-Authored-By: unknown <>
Co-Authored-By: unknown <>
hbjORbj
left a comment
There was a problem hiding this comment.
Had a discussion with Rajiv off github. He will implement some improvements.
There was a problem hiding this comment.
1 issue found across 2 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/features/auth/lib/next-auth-options.ts">
<violation number="1" location="packages/features/auth/lib/next-auth-options.ts:914">
P1: `profileId` regression: the database-derived profile ID from `determineProfile` is no longer used. On first OAuth login (or when profile switcher is disabled), `token.profileId` is likely null, so this sets `profileId: null` in the JWT even though `determineProfile` returned a valid profile with an `id`. The previous code `profileResult.id ?? token.profileId ?? null` correctly prioritized the determined profile's ID.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Devin AI is addressing Cubic AI's review feedbackA Devin session has been created to address the issues identified by Cubic AI. |
…h 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>
|
Fixed the Root cause: The refactor changed Fix: Restored the original priority chain by destructuring const { upId, id: visitorProfileId } = determineProfile({ profiles: allProfiles, token });
// ...
profileId: visitorProfileId ?? token.profileId ?? null,This ensures that on first OAuth login (or when profile switcher is disabled), the JWT correctly receives the database-derived profile ID rather than |
Co-Authored-By: rajiv@cal.com <sahalrajiv6900@gmail.com>
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>
…roxy/github.com/calcom/cal.com into microsoft-login-flow
There was a problem hiding this comment.
1 issue found across 6 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/web/modules/signup-view.tsx">
<violation number="1">
P1: Custom agent: **Avoid Logging Sensitive Information**
Avoid logging PII in analytics events. This GTM event includes `email` and `user` (username), which violates the rule against logging sensitive information. Remove or anonymize these fields before sending.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Devin AI is addressing Cubic AI's review feedbackNew feedback has been sent to the existing Devin session. ✅ No changes pushed — the signup-view.tsx issue (PII in GTM analytics events) has confidence 8/10, below the 9/10 threshold. |
What does this PR do?
Summary by cubic
Adds Microsoft (Azure AD) sign-in/sign-up behind a feature flag and refreshes the login/signup UI. On first Microsoft sign-in, auto-installs the Office 365 default calendar and syncs the user’s profile photo while keeping avatar URLs stable. Also fixes a regression that could set profileId to null on first OAuth login.
New Features
Migration
Written for commit 74753dc. Summary will update on new commits.
Updates since last revision
Addressed PR review feedback (hbjORbj's comments):
!):OUTLOOK_CLIENT_ID!/OUTLOOK_CLIENT_SECRET!replaced with a guard clause (if (... && OUTLOOK_CLIENT_ID && OUTLOOK_CLIENT_SECRET));account.access_token!replaced with a conditional check.as anycasts:(profile as any)?.email_verifiedand(profile as any)?.xms_edovreplaced withRecord<string, unknown>typed variable.OUTLOOK_CLIENT_ID,OUTLOOK_CLIENT_SECRET,IS_OUTLOOK_LOGIN_ENABLEDfrompackages/features/auth/lib/outlook.tsinto@calcom/lib/constantsalongsideMICROSOFT_CALENDAR_SCOPES.outlook.tsnow re-exports from constants.getNextAuthProviderNameusage inget.handler.ts(AZUREAD enum → "azure-ad" provider name, which.toLowerCase()would not produce).Latest fix (Cubic AI feedback — confidence 9/10)
profileIdin OAuth JWT (next-auth-options.ts): A prior refactor changeddetermineProfile's destructuring to only captureupId, dropping the profileid. This causedprofileIdin the JWT to fall back totoken.profileId ?? null, which isnullon first OAuth login or when the profile switcher is disabled. Fixed by destructuringidfromdetermineProfileand restoring the priority chain:visitorProfileId ?? token.profileId ?? null.Link to Devin run: https://app.devin.ai/sessions/1c553264210348f5a8bdd9c8d15afde1
Requested by: bot_apk (apk@cognition.ai)
Mandatory Tasks (DO NOT REMOVE)
.env.example.How should this be tested?
MS_GRAPH_CLIENT_ID— Azure AD app client IDMS_GRAPH_CLIENT_SECRET— Azure AD app client secretOUTLOOK_LOGIN_ENABLED=true/auth/login— a "Microsoft" button should appear alongside Google (if enabled).profileId(notnull). Check session token or logs to confirmprofileIdis set correctly.🔍 Items for human reviewer attention
BackgroundGrid,@coss/uicomponents, layout changes). Please verify visual correctness across light/dark modes.xms_edovhandling) — security-sensitive. Confirm the logic correctly handlesboolean,string "1", andnumber 1values.getNextAuthProviderNameis used consistently and correctly.Record<string, unknown>for OAuth profile claims is better thanas any, but still loosely typed. Acceptable trade-off?determineProfilereturns{ id, upId }and thatidis correctly used asvisitorProfileIdin the JWT. Confirm first-time OAuth logins receive a validprofileId.Checklist