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
4 changes: 2 additions & 2 deletions src/modules/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,14 @@ async function isDisabledAccount(supabase: SupabaseClient, userId: string | null

if (error) {
console.error('Error checking account status:', error)
return true
return false
}

return !!isDisabled
}
catch (error) {
console.error('Error checking if account is disabled:', error)
return true
return false
}
}

Expand Down
41 changes: 35 additions & 6 deletions tests/auth-sso-provisioning.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ describe('auth guard SSO provisioning', () => {
})
})

it.concurrent('fails closed when the disabled-account RPC errors', async () => {
it.concurrent('continues navigation when the disabled-account RPC errors', async () => {
await withTestContext(async (context) => {
context.mockRpc.mockResolvedValueOnce({
data: null,
Expand All @@ -341,13 +341,42 @@ describe('auth guard SSO provisioning', () => {
next,
)

expect(context.organizationStore.fetchOrganizations).not.toHaveBeenCalled()
expect(next).toHaveBeenCalledWith({
expect(context.organizationStore.fetchOrganizations).toHaveBeenCalled()
expect(next).toHaveBeenCalledWith()
expect(next).not.toHaveBeenCalledWith(expect.objectContaining({
path: '/accountDisabled',
query: {
to: '/dashboard',
},
}))
})
})

it.concurrent('redirects active users away from the recovery page when the disabled-account check errors', async () => {
await withTestContext(async (context) => {
context.mainStore.auth = {
id: 'user-123',
email: 'user@managed.test',
email_confirmed_at: '2026-04-15T10:00:00.000Z',
}
context.mockRpc.mockResolvedValueOnce({
data: null,
error: new Error('rpc failed'),
})

const guard = await getGuard()
const next = vi.fn()

await guard(
{
path: '/accountDisabled',
fullPath: '/accountDisabled?to=/apps/app-123',
meta: { middleware: 'auth' },
query: { to: '/apps/app-123' },
},
{ path: '/apps/app-123', fullPath: '/apps/app-123', meta: { middleware: 'auth' }, query: {} },
next,
)

expect(next).toHaveBeenCalledTimes(1)
expect(next).toHaveBeenCalledWith('/apps/app-123')
})
})

Expand Down
Loading