Generator Changes at 9/28/2025 6:19:21 AM

This commit is contained in:
MeysamMoghaddam
2025-09-28 06:30:13 +03:30
parent 1a99a88552
commit a3b7302d90
16 changed files with 534 additions and 6 deletions

View File

@@ -14,7 +14,9 @@ public class CreateNewOtpTokenCommandHandler : IRequestHandler<CreateNewOtpToken
_cfg = cfg;
}
const int CodeLength = 6; // 4-6 مناسب است
const int CodeLength = 6;
const int MaxAttempts = 5; // محدودیت تلاش
static readonly TimeSpan Ttl = TimeSpan.FromMinutes(2);
static readonly TimeSpan Cooldown = TimeSpan.FromSeconds(60); // فاصله ارسال مجدد
public async Task<CreateNewOtpTokenResponseDto> Handle(CreateNewOtpTokenCommand request,
@@ -57,7 +59,9 @@ public class CreateNewOtpTokenCommandHandler : IRequestHandler<CreateNewOtpToken
{
Success = true,
Message = "کد ارسال شد.",
Code = code
Code = code,
RemainingAttempts = MaxAttempts,
RemainingSeconds = Ttl.Seconds
};
}

View File

@@ -7,5 +7,9 @@ public class CreateNewOtpTokenResponseDto
public string Message { get; set; }
//کد
public string? Code { get; set; }
//تلاش باقی مانده
public int RemainingAttempts { get; set; }
//ثانیه باقی مانده
public int RemainingSeconds { get; set; }
}

View File

@@ -51,7 +51,9 @@ public class VerifyOtpTokenCommandHandler : IRequestHandler<VerifyOtpTokenComman
Mobile = mobile,
ReferralCode = UtilExtensions.Generate(digits: 10, firstDigitNonZero: true),
IsMobileVerified = true,
MobileVerifiedAt = now
MobileVerifiedAt = now,
IsRulesAccepted = true,
RulesAcceptedAt = now,
};
await _context.Users.AddAsync(user, cancellationToken);
user.AddDomainEvent(new CreateNewUserEvent(user));
@@ -71,7 +73,9 @@ public class VerifyOtpTokenCommandHandler : IRequestHandler<VerifyOtpTokenComman
{
Success = true,
Message = "اعتبارسنجی موفق.",
UserId = user.Id
UserId = user.Id,
RemainingAttempts = MaxAttempts,
RemainingSeconds = (otp.ExpiresAt - now).Seconds
};
}

View File

@@ -7,5 +7,9 @@ public class VerifyOtpTokenResponseDto
public string Message { get; set; }
//شناسه کاربر
public long? UserId { get; set; }
//تلاش باقی مانده
public int RemainingAttempts { get; set; }
//ثانیه باقی مانده
public int RemainingSeconds { get; set; }
}