mirror of
https://git.meshkee.com/Meshkee/backend.git
synced 2026-08-11 22:30:59 +04:30
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:
co-authored by
Cursor
parent
723948cd5e
commit
9455cd9fab
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user