Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 28 additions & 8 deletions apps/web/src/app/api/mcp-oauth/callback/__tests__/route.test.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions apps/web/src/app/api/mcp-oauth/callback/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ import { authorize } from '@/lib/server';
import { bootstrapWebRuntimeEnv } from '@/lib/server/bootstrap-runtime-env';
import { getPublicAppUrl } from '@/lib/server/get-public-app-url';
import { logger } from '@/lib/server/logger';
import { hydrateLinearMcpConnectionAfterOauth } from '@/lib/server/mcp-linear';
import {
hydrateLinearMcpConnectionAfterOauth,
LinearReplayIdentityMismatchError,
} from '@/lib/server/mcp-linear';
import type {
McpOAuthErrorReason,
McpOAuthResult,
Expand Down Expand Up @@ -317,17 +320,17 @@ export async function GET(request: NextRequest) {
redirectUri,
);

failureStage = 'token_storage';
await storeTokens(resolvedConnectionId, tokens);

if (integration.id === 'linear') {
failureStage = 'linear_metadata';
await hydrateLinearMcpConnectionAfterOauth({
connection,
accessToken: tokens.access_token,
tokens,
replayToken: oauthState.replayToken,
enabledByUserId: userId,
});
} else {
failureStage = 'token_storage';
await storeTokens(resolvedConnectionId, tokens);
}

if (requiresOrgAdmin) {
Expand Down Expand Up @@ -365,7 +368,7 @@ export async function GET(request: NextRequest) {
'MCP OAuth callback failed',
);

if (connectionId) {
if (connectionId && !(error instanceof LinearReplayIdentityMismatchError)) {
try {
await updateAuthStatus(connectionId, 'error');
} catch (statusError) {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions apps/web/src/app/api/mcp-oauth/replay/[token]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ export async function GET(
mcpConnections.connectionRole,
],
set: {
userId: targetUserId,
authConfig: null,
enabled: false,
authStatus: 'pending',
updatedAt: new Date(),
},
})
Expand Down
139 changes: 139 additions & 0 deletions apps/web/src/lib/server/mcp-linear.test.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading