refactor: integrate Better-Auth for authentication and remove Supabase dependencies
This commit is contained in:
@@ -5,8 +5,8 @@ import type { CreateComplexInput } from '@repo/api-contract';
|
||||
export async function createComplexHandler(c: AppContext) {
|
||||
const payload = c.req.valid('json' as never) as CreateComplexInput;
|
||||
|
||||
const authUser = c.get('authUser');
|
||||
const adminEmail = authUser.email;
|
||||
const user = c.get('user');
|
||||
const adminEmail = user.email;
|
||||
|
||||
if (!adminEmail) {
|
||||
return c.json({ message: 'El usuario autenticado no tiene email.' }, 400);
|
||||
|
||||
@@ -2,7 +2,7 @@ import { listMyComplexes } from '@/modules/complex/services/complex.service';
|
||||
import type { AppContext } from '@/types/hono';
|
||||
|
||||
export async function listMyComplexesHandler(c: AppContext) {
|
||||
const appUserId = c.get('appUserId');
|
||||
const complexes = await listMyComplexes(appUserId);
|
||||
const user = c.get('user');
|
||||
const complexes = await listMyComplexes(user.id);
|
||||
return c.json(complexes);
|
||||
}
|
||||
|
||||
@@ -93,9 +93,9 @@ export async function getComplexBySlug(slug: string) {
|
||||
});
|
||||
}
|
||||
|
||||
export async function listMyComplexes(appUserId: string) {
|
||||
export async function listMyComplexes(userId: string) {
|
||||
const complexUsers = await db.complexUser.findMany({
|
||||
where: { userId: appUserId },
|
||||
where: { userId },
|
||||
include: {
|
||||
complex: true,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user