Error
Something went wrong.
This commit is contained in:
+19
-1
@@ -1,4 +1,3 @@
|
||||
|
||||
'use server';
|
||||
|
||||
import { z } from 'zod';
|
||||
@@ -14,6 +13,25 @@ const formSchema = z.object({
|
||||
|
||||
type UserFormValues = z.infer<typeof formSchema>;
|
||||
|
||||
type User = {
|
||||
id: string;
|
||||
name: string | null;
|
||||
email: string;
|
||||
password?: string | null;
|
||||
};
|
||||
|
||||
export async function getUserByEmail(email: string): Promise<User | null> {
|
||||
try {
|
||||
const stmt = db.prepare('SELECT id, name, email, password FROM users WHERE email = ?');
|
||||
const user = stmt.get(email) as User | undefined;
|
||||
return user || null;
|
||||
} catch (error) {
|
||||
console.error('Failed to get user by email:', error);
|
||||
throw new Error('Database error while fetching user.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the currently logged-in user from the session.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user