File tree Expand file tree Collapse file tree
lib/credentials/application Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33import { useState } from 'react'
44import { AuthIdentity , AuthButton as Chip } from '@sim/auth-ui'
5+ import { isApiClientError } from '@/lib/api/client/errors'
56import { requestJson } from '@/lib/api/client/request'
67import { startCredentialConnectionContract } from '@/lib/api/contracts/credentials'
78import { 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 }
Original file line number Diff line number Diff 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'
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments