feat(auth): implement better authentication system with user sessions and password management

- Added user, session, account, and verification models to Prisma schema.
- Integrated better-auth for user authentication with email and password.
- Created auth middleware for session validation.
- Implemented auth context and client in frontend for managing user sessions.
- Added login and settings pages for user authentication and password management.
- Updated routes to include authentication checks and user-specific content.
- Enhanced UI components to reflect authentication state.
This commit is contained in:
Jose Selesan
2026-05-29 16:03:38 -03:00
parent de57ea4bd7
commit 9482fea7f2
29 changed files with 621 additions and 21 deletions

View File

@@ -39,7 +39,7 @@ export type DailyQuote = {
};
async function fetcher<T>(url: string): Promise<T> {
const res = await fetch(url);
const res = await fetch(url, { credentials: "include" });
if (!res.ok) {
throw new Error(`API error: ${res.status} ${res.statusText}`);
}
@@ -51,6 +51,7 @@ async function mutator<T>(url: string, method: string, body?: unknown): Promise<
method,
headers: { "Content-Type": "application/json" },
body: body ? JSON.stringify(body) : undefined,
credentials: "include",
});
if (!res.ok) {
throw new Error(`API error: ${res.status} ${res.statusText}`);
@@ -235,6 +236,7 @@ export function importExpenses(file: File): Promise<ImportExpensesResult> {
return fetch("/api/expenses/import", {
method: "POST",
body: formData,
credentials: "include",
}).then((r) => {
if (!r.ok) throw new Error(`API error: ${r.status} ${r.statusText}`);
return r.json();
@@ -247,6 +249,7 @@ export function importPeriodicExpenses(file: File): Promise<ImportResult> {
return fetch("/api/periodic-expenses/import", {
method: "POST",
body: formData,
credentials: "include",
}).then((r) => {
if (!r.ok) throw new Error(`API error: ${r.status} ${r.statusText}`);
return r.json();