Skip to content

Commit 77dc1ca

Browse files
committed
fix(oauth): send an expired session back through sign-in from the connect page
1 parent 47e785c commit 77dc1ca

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

‎apps/sim/app/oauth/connect/connect-confirmation.tsx‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { useState } from 'react'
44
import { AuthIdentity, AuthButton as Chip } from '@sim/auth-ui'
5+
import { isApiClientError } from '@/lib/api/client/errors'
56
import { requestJson } from '@/lib/api/client/request'
67
import { startCredentialConnectionContract } from '@/lib/api/contracts/credentials'
78
import { DesktopHandoffShell } from '@/app/desktop/components/desktop-handoff-shell'
@@ -43,6 +44,12 @@ export function ConnectConfirmation({
4344
if (callbackURL) launch.searchParams.set('callbackURL', callbackURL)
4445
window.location.assign(launch.toString())
4546
} catch (error) {
47+
if (isApiClientError(error) && error.status === 401) {
48+
// The session ended after this page rendered: sign in again, then return here.
49+
const here = `${window.location.pathname}${window.location.search}`
50+
window.location.assign(`/login?callbackUrl=${encodeURIComponent(here)}`)
51+
return
52+
}
4653
setErrorMessage(error instanceof Error ? error.message : null)
4754
setStatus('error')
4855
}

‎apps/sim/lib/credentials/application/connection-target.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export interface ResolvedCredentialConnectionTarget {
2121
displayName?: string
2222
}
2323

24-
export class CredentialConnectionProviderMismatchError extends OrchestrationError {
24+
class CredentialConnectionProviderMismatchError extends OrchestrationError {
2525
constructor() {
2626
super('validation', 'Credential provider does not match the requested OAuth provider')
2727
this.name = 'CredentialConnectionProviderMismatchError'

‎scripts/check-test-types.baseline.json‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
"TS2739": 2
2727
},
2828
"apps/sim/app/api/auth/oauth2/authorize/route.test.ts": {
29-
"TS2345": 2,
30-
"TS2554": 1
29+
"TS2345": 2
3130
},
3231
"apps/sim/app/api/auth/oauth2/callback/quickbooks/route.test.ts": {
3332
"TS2554": 3

0 commit comments

Comments
 (0)