full project: admin panel, backend modules, docs

This commit is contained in:
Lizandro Guarnizo
2026-06-03 22:11:01 -05:00
parent 1635723035
commit afc096d552
94 changed files with 15994 additions and 240 deletions
+32 -3
View File
@@ -16,7 +16,7 @@ export class AuthService {
const password_hash = await bcrypt.hash(password, 10);
const user = await this.prisma.users.create({
data: { email, password_hash, name, is_email_verified: true },
data: { email, password_hash, name },
});
return this.generateToken(user);
@@ -36,14 +36,36 @@ export class AuthService {
let user = await this.prisma.users.findUnique({ where: { phone } });
if (!user) {
user = await this.prisma.users.create({
data: { phone, name: name || phone, is_phone_verified: true },
data: { phone, name: name || phone },
});
}
return this.generateToken(user);
}
async verifyOtpAndLinkPhone(userId: string, phone: string) {
const existing = await this.prisma.users.findUnique({ where: { phone } });
if (existing && existing.id !== userId) {
throw new ConflictException('Teléfono ya registrado por otro usuario');
}
return this.prisma.users.update({
where: { id: userId },
data: { phone, is_phone_verified: true },
});
}
async linkEmail(userId: string, email: string, password: string) {
const existing = await this.prisma.users.findUnique({ where: { email } });
if (existing) throw new ConflictException('Email ya registrado');
const password_hash = await bcrypt.hash(password, 10);
return this.prisma.users.update({
where: { id: userId },
data: { email, password_hash },
});
}
async me(userId: string) {
return this.prisma.users.findUnique({
const user = await this.prisma.users.findUnique({
where: { id: userId },
include: {
professionals: {
@@ -52,6 +74,13 @@ export class AuthService {
reputations: true,
},
});
if (!user) throw new UnauthorizedException('Usuario no encontrado');
return user;
}
async getProfessionalId(userId: string): Promise<string | null> {
const prof = await this.prisma.professionals.findUnique({ where: { user_id: userId } });
return prof?.id || null;
}
private generateToken(user: any) {