feat(profile): enforce uniqueness of national_code across user profiles and update related error handling
This commit is contained in:
@@ -145,6 +145,19 @@ class PatientController extends BaseController
|
||||
$patient = $this->userRepo->findByMobile($mobile);
|
||||
}
|
||||
|
||||
// کد ملی باید در سطح بیمار یکتا باشد: اگر به پروفایلِ کاربر دیگری تعلق دارد، رد کن
|
||||
if ($nationalCode !== '') {
|
||||
$owner = $this->profileRepo->findOneByNationalCode($nationalCode);
|
||||
if ($owner !== null && ($patient === null || $owner->getUser()->getId() !== $patient->getId())) {
|
||||
return $this->error(
|
||||
ErrorCodes::ERR_PROFILE_NATIONAL_CODE_TAKEN,
|
||||
'این کد ملی قبلاً برای کاربر دیگری ثبت شده است',
|
||||
409,
|
||||
'national_code'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// بیمار جدید بدون ثبتنام قبلی: موبایل + نام آمده ولی کاربری وجود ندارد
|
||||
if ($patient === null) {
|
||||
if ($mobile === '' || $name === '') {
|
||||
|
||||
Reference in New Issue
Block a user