feat(giftcard): add customer giftcard/mine endpoint; fix admin/app password digit normalization

This commit is contained in:
2026-09-09 16:57:20 +03:30
parent 741faa38fb
commit 0fa2b4d1f5
8 changed files with 243 additions and 8 deletions
+22 -2
View File
@@ -129,12 +129,32 @@ class Customer extends Authenticatable implements JWTSubject
->first();
}
// hash password
// hash password — ارقام فارسی/عربی را قبل از هش انگلیسی کن (لاگین اپ هم انگلیسی می‌فرستد)
public function setPasswordAttribute($value){
if ($value === null || $value === '') {
return;
}
$this->attributes['password'] = Hash::make($value);
$value = trim((string) $value);
if ($value === '') {
return;
}
// اگر از قبل bcrypt است دوباره هش نکن
if (preg_match('/^\$2[ayb]\$.{56}$/', $value) === 1) {
$this->attributes['password'] = $value;
return;
}
$this->attributes['password'] = Hash::make(self::normalizeCredentialDigits($value));
}
/** ارقام فارسی/عربی → لاتین (برای رمز و موبایل در احراز هویت) */
public static function normalizeCredentialDigits(string $value): string
{
$persian = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'];
$arabic = ['٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩'];
$latin = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
return str_replace(array_merge($persian, $arabic), array_merge($latin, $latin), $value);
}
public function setBirthDateAttribute($value): void