Allow creating a business with an existing active owner cell number.

Reuse the existing user as owner instead of rejecting duplicate cells, so one person can own multiple businesses.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Alireza Hassani
2026-07-26 14:45:02 +03:30
co-authored by Cursor
parent 723948cd5e
commit 9455cd9fab
+6 -1
View File
@@ -492,8 +492,13 @@ export class BusinessAdminService {
where: { cellNumber: dto.ownerCellNumber }, where: { cellNumber: dto.ownerCellNumber },
}); });
// Users can own multiple businesses. If the cell number already exists,
// leave that user unchanged and only attach the new business as owner.
if (existing) { if (existing) {
throw new ConflictException('A user with this cell number already exists'); if (!existing.isActive) {
throw new BadRequestException('Owner user is inactive');
}
return existing;
} }
const passwordHash = await bcrypt.hash(dto.ownerPassword, 10); const passwordHash = await bcrypt.hash(dto.ownerPassword, 10);