test the login yourself4

This commit is contained in:
Leon Serfaty G
2025-09-01 07:24:29 +00:00
parent fa221bbdc1
commit c5ebbc5f77
8 changed files with 136 additions and 113 deletions
+4 -1
View File
@@ -1,7 +1,8 @@
'use server';
import { z } from 'zod';
import db from '@/lib/db';
import getDb from '@/lib/db';
import { revalidatePath } from 'next/cache';
import { auth } from '@/auth';
@@ -21,6 +22,7 @@ type User = {
};
export async function getUserByEmail(email: string): Promise<User | null> {
const db = getDb();
try {
const stmt = db.prepare('SELECT id, name, email, password FROM users WHERE email = ?');
const user = stmt.get(email) as User | undefined;
@@ -64,6 +66,7 @@ export async function updateUser(data: UserFormValues): Promise<{ success: boole
const { name, email, password } = validation.data;
try {
const db = getDb();
const userId = session.user.id;
// Check if the new email is already taken by another user