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.
This commit is contained in:
@@ -1,7 +1,21 @@
|
||||
import { createAuthClient } from "better-auth/client";
|
||||
/**
|
||||
* Cliente Better Auth para frontend SvelteKit
|
||||
*
|
||||
* Configurado para trabalhar com Convex via plugin convexClient.
|
||||
* Este cliente será usado para autenticação quando Better Auth estiver ativo.
|
||||
*/
|
||||
import { createAuthClient } from "better-auth/svelte";
|
||||
import { convexClient } from "@convex-dev/better-auth/client/plugins";
|
||||
|
||||
export const authClient = createAuthClient({
|
||||
baseURL: "http://localhost:5173",
|
||||
plugins: [convexClient()],
|
||||
// Base URL da API Better Auth (mesma do app)
|
||||
baseURL: typeof window !== "undefined"
|
||||
? window.location.origin // Usar origem atual em produção
|
||||
: "http://localhost:5173", // Fallback para desenvolvimento
|
||||
plugins: [
|
||||
// Plugin Convex integra Better Auth com Convex backend
|
||||
convexClient({
|
||||
convexUrl: import.meta.env.PUBLIC_CONVEX_URL || "",
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user