Files
sgse-app/apps/web/src/lib/hooks/convexAuth.ts
deyvisonwanderley 06f03b53e5 feat: integrate Better Auth and enhance authentication flow
- Added Better Auth integration to the web application, allowing for dual login support with both custom and Better Auth systems.
- Updated authentication client configuration to dynamically set the base URL based on the environment.
- Enhanced chat components to utilize user authentication status, improving user experience and security.
- Refactored various components to support Better Auth, including error handling and user identity management.
- Improved notification handling and user feedback mechanisms during authentication processes.
2025-11-06 09:35:36 -03:00

27 lines
1.0 KiB
TypeScript

/**
* Hook para garantir que o cliente Convex tenha o token configurado
*
* NOTA: O token é passado automaticamente via monkey patch no +layout.svelte
* Este hook existe apenas para compatibilidade, mas não faz nada agora.
* O token é injetado via headers nas requisições HTTP através do monkey patch.
*/
import { authStore } from "$lib/stores/auth.svelte";
/**
* Configura o token no cliente Convex
*
* IMPORTANTE: O token agora é passado automaticamente via monkey patch global.
* Este hook é mantido para compatibilidade mas não precisa ser chamado.
*
* @param client - Cliente Convex retornado por useConvexClient()
*/
export function setupConvexAuth(client: unknown) {
// Token é passado automaticamente via monkey patch em +layout.svelte
// Não precisamos fazer nada aqui, apenas manter compatibilidade
if (import.meta.env.DEV && client && authStore.token) {
console.log("✅ [setupConvexAuth] Token disponível (gerenciado via monkey patch):", authStore.token.substring(0, 20) + "...");
}
}