Files
cameleer-saas/ui/src/auth/useAuth.ts
hsiegeln 2cb818ec71
All checks were successful
CI / build (push) Successful in 2m45s
CI / docker (push) Successful in 1m50s
fix: prevent logout loop by showing signed-out state instead of auto-redirecting
After logout, redirect to /platform/login?signed_out which shows a
"Signed out" card with a "Sign in again" button instead of immediately
redirecting back to Logto OIDC (which would auto-authenticate if the
Logto session cookie persists).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-25 18:52:26 +02:00

21 lines
504 B
TypeScript

import { useLogto } from '@logto/react';
import { useCallback } from 'react';
import { useOrgStore } from './useOrganization';
export function useAuth() {
const { isAuthenticated, isLoading, signOut, signIn } = useLogto();
const { currentTenantId } = useOrgStore();
const logout = useCallback(() => {
signOut(window.location.origin + '/platform/login?signed_out');
}, [signOut]);
return {
isAuthenticated,
isLoading,
tenantId: currentTenantId,
logout,
signIn,
};
}