Merge pull request 'Added persian error messages (only for auth for now)' (#236) from s.yahyaee/yara724-api:main into main

Reviewed-on: Yara724/api#236
This commit is contained in:
2026-07-31 20:01:14 +03:30
3 changed files with 15 additions and 15 deletions

View File

@@ -210,13 +210,13 @@ export class ActorAuthService {
): Promise<any> { ): Promise<any> {
const user = await this.dynamicDbController(role, username); const user = await this.dynamicDbController(role, username);
if (!user) { if (!user) {
throw new NotFoundException("Actor account not found"); throw new NotFoundException("حساب کاربری یافت نشد");
} }
if (user.role !== role) { if (user.role !== role) {
throw new UnauthorizedException("user not assigned to this role"); throw new UnauthorizedException("این حساب به نقش انتخاب‌شده تعلق ندارد");
} }
if (!(await this.hashService.compare(pass, user.password))) { if (!(await this.hashService.compare(pass, user.password))) {
throw new UnauthorizedException("password is incorrect or access Denied"); throw new UnauthorizedException("نام کاربری یا رمز عبور اشتباه است");
} }
return user; return user;
} }
@@ -229,7 +229,7 @@ export class ActorAuthService {
const username = this.parseActorLoginUsername(body); const username = this.parseActorLoginUsername(body);
const password = body?.password; const password = body?.password;
if (typeof password !== "string" || !password) { if (typeof password !== "string" || !password) {
throw new BadRequestException("password is required"); throw new BadRequestException("رمز عبور الزامی است");
} }
const captchaId = const captchaId =
typeof body?.captchaId === "string" ? body.captchaId : undefined; typeof body?.captchaId === "string" ? body.captchaId : undefined;

View File

@@ -12,12 +12,12 @@ export enum CaptchaAuthErrorCode {
const messages: Record<CaptchaAuthErrorCode, string> = { const messages: Record<CaptchaAuthErrorCode, string> = {
[CaptchaAuthErrorCode.CAPTCHA_REQUIRED]: [CaptchaAuthErrorCode.CAPTCHA_REQUIRED]:
"Captcha is required. Request a new captcha image first.", "کپچا الزامی است. ابتدا تصویر کپچا را دریافت کنید.",
[CaptchaAuthErrorCode.CAPTCHA_NOT_FOUND]: [CaptchaAuthErrorCode.CAPTCHA_NOT_FOUND]:
"Captcha id was not found. Request a new captcha image.", "شناسه کپچا یافت نشد. تصویر جدیدی درخواست دهید.",
[CaptchaAuthErrorCode.CAPTCHA_EXPIRED]: [CaptchaAuthErrorCode.CAPTCHA_EXPIRED]:
"Captcha has expired. Request a new captcha image.", "کپچا منقضی شده است. تصویر جدیدی درخواست دهید.",
[CaptchaAuthErrorCode.CAPTCHA_INVALID]: "Captcha is invalid.", [CaptchaAuthErrorCode.CAPTCHA_INVALID]: "کپچا نامعتبر است.",
}; };
export function captchaAuthErrorBody(code: CaptchaAuthErrorCode) { export function captchaAuthErrorBody(code: CaptchaAuthErrorCode) {

View File

@@ -15,15 +15,15 @@ export enum UserAuthErrorCode {
} }
const messages: Record<UserAuthErrorCode, string> = { const messages: Record<UserAuthErrorCode, string> = {
[UserAuthErrorCode.USER_NOT_FOUND]: "User not found", [UserAuthErrorCode.USER_NOT_FOUND]: "کاربر یافت نشد",
[UserAuthErrorCode.OTP_REQUIRED]: "Please request an OTP first", [UserAuthErrorCode.OTP_REQUIRED]: "ابتدا درخواست کد یکبار مصرف دهید",
[UserAuthErrorCode.OTP_EXPIRED]: "OTP has expired", [UserAuthErrorCode.OTP_EXPIRED]: "کد یکبار مصرف منقضی شده است",
[UserAuthErrorCode.OTP_INVALID]: "OTP is invalid", [UserAuthErrorCode.OTP_INVALID]: "کد یکبار مصرف نامعتبر است",
[UserAuthErrorCode.OTP_REQUEST_TOO_SOON]: [UserAuthErrorCode.OTP_REQUEST_TOO_SOON]:
"Wait for expiry time to finish before requesting another OTP", "لطفاً تا انقضای کد فعلی صبر کنید",
[UserAuthErrorCode.LINK_NOT_FOUND]: "Linked SMS token was not found", [UserAuthErrorCode.LINK_NOT_FOUND]: "لینک پیامکی یافت نشد",
[UserAuthErrorCode.LINK_MOBILE_MISMATCH]: [UserAuthErrorCode.LINK_MOBILE_MISMATCH]:
"This mobile number is not allowed to use this SMS link", "این شماره موبایل مجاز به استفاده از این لینک نیست",
}; };
export function userAuthErrorBody(code: UserAuthErrorCode) { export function userAuthErrorBody(code: UserAuthErrorCode) {