diff --git a/hesabixAPI/app/core/i18n.py b/hesabixAPI/app/core/i18n.py index b4f3854..b176ac6 100644 --- a/hesabixAPI/app/core/i18n.py +++ b/hesabixAPI/app/core/i18n.py @@ -38,6 +38,7 @@ class Translator: "INVALID_IDENTIFIER": "Identifier must be a valid email or mobile number.", "EMAIL_IN_USE": "Email is already in use.", "MOBILE_IN_USE": "Mobile number is already in use.", + "INVALID_MOBILE": "Invalid mobile number.", "ACCOUNT_DISABLED": "Your account is disabled.", "RESET_TOKEN_INVALID_OR_EXPIRED": "Reset token is invalid or expired.", "VALIDATION_ERROR": "Validation error", @@ -55,6 +56,7 @@ class Translator: "INVALID_IDENTIFIER": "شناسه باید ایمیل یا شماره موبایل معتبر باشد.", "EMAIL_IN_USE": "این ایمیل قبلاً استفاده شده است.", "MOBILE_IN_USE": "این شماره موبایل قبلاً استفاده شده است.", + "INVALID_MOBILE": "شماره موبایل نامعتبر است.", "ACCOUNT_DISABLED": "حساب کاربری شما غیرفعال است.", "RESET_TOKEN_INVALID_OR_EXPIRED": "توکن بازنشانی نامعتبر یا منقضی شده است.", "VALIDATION_ERROR": "خطای اعتبارسنجی", diff --git a/hesabixAPI/app/services/auth_service.py b/hesabixAPI/app/services/auth_service.py index 486dce8..b02b959 100644 --- a/hesabixAPI/app/services/auth_service.py +++ b/hesabixAPI/app/services/auth_service.py @@ -54,6 +54,10 @@ def register_user(*, db: Session, first_name: str | None, last_name: str | None, mobile_n = _normalize_mobile(mobile) if not email_n and not mobile_n: from app.core.responses import ApiError + # اگر کاربر موبایل وارد کرده اما نامعتبر بوده، پیام دقیق‌تر بدهیم + if mobile and mobile.strip(): + raise ApiError("INVALID_MOBILE", "Invalid mobile number") + # در غیر این صورت، هیچ شناسهٔ معتبری ارائه نشده است raise ApiError("IDENTIFIER_REQUIRED", "Email or mobile is required") repo = UserRepository(db) diff --git a/hesabixAPI/locales/fa/LC_MESSAGES/messages.mo b/hesabixAPI/locales/fa/LC_MESSAGES/messages.mo index 1dbf568..82939fa 100644 Binary files a/hesabixAPI/locales/fa/LC_MESSAGES/messages.mo and b/hesabixAPI/locales/fa/LC_MESSAGES/messages.mo differ diff --git a/hesabixAPI/locales/fa/LC_MESSAGES/messages.po b/hesabixAPI/locales/fa/LC_MESSAGES/messages.po index 89c248c..77889fe 100644 --- a/hesabixAPI/locales/fa/LC_MESSAGES/messages.po +++ b/hesabixAPI/locales/fa/LC_MESSAGES/messages.po @@ -52,6 +52,9 @@ msgstr "این ایمیل قبلاً استفاده شده است." msgid "MOBILE_IN_USE" msgstr "این شماره موبایل قبلاً استفاده شده است." +msgid "INVALID_MOBILE" +msgstr "شماره موبایل نامعتبر است." + msgid "ACCOUNT_DISABLED" msgstr "حساب کاربری شما غیرفعال است." diff --git a/hesabixUI/hesabix_ui/lib/l10n/app_localizations_fa.dart b/hesabixUI/hesabix_ui/lib/l10n/app_localizations_fa.dart index e58acd4..38bcb2c 100644 --- a/hesabixUI/hesabix_ui/lib/l10n/app_localizations_fa.dart +++ b/hesabixUI/hesabix_ui/lib/l10n/app_localizations_fa.dart @@ -100,7 +100,8 @@ class AppLocalizationsFa extends AppLocalizations { String get registerFailed => 'عضویت ناموفق بود. لطفاً دوباره تلاش کنید.'; @override - String get resetFailed => 'ارسال کد بازیابی ناموفق بود. لطفاً دوباره تلاش کنید.'; + String get resetFailed => + 'ارسال کد بازیابی ناموفق بود. لطفاً دوباره تلاش کنید.'; @override String get fixFormErrors => 'لطفاً خطاهای فرم را برطرف کنید.';