From aeff492ed452ffc20880eaa3d7c1acf398829161 Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Fri, 19 Mar 2021 11:27:28 +0330 Subject: [PATCH] #97 lockout was enabled, making error messages more understandable. --- .../Services/Implementation/AppUserService.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/RSecurityBackend/Services/Implementation/AppUserService.cs b/RSecurityBackend/Services/Implementation/AppUserService.cs index 62347705..b129fc38 100644 --- a/RSecurityBackend/Services/Implementation/AppUserService.cs +++ b/RSecurityBackend/Services/Implementation/AppUserService.cs @@ -66,19 +66,29 @@ namespace RSecurityBackend.Services.Implementation appUser = await _userManager.FindByEmailAsync(loginViewModel.Username); if(appUser == null) { - return new RServiceResult(null, "Invalid username."); + return new RServiceResult(null, "نام کاربری و/یا رمز نادرست است."); } } var result = await _signInManager.CheckPasswordSignInAsync(appUser, loginViewModel.Password, true); + if(result.IsLockedOut) + { + return new RServiceResult(null, "نام کاربری شما به دلیل ورود متوالی ۵ بارهٔ رمزهای اشتباه قفل شده است. لطفاً ۵ دقیقهٔ‌دیگر مجدداً تلاش کنید."); + } + + if(result.IsNotAllowed || result.RequiresTwoFactor) + { + return new RServiceResult(null, result.ToString()); + } + if (!result.Succeeded) { - return new RServiceResult(null, "Invalid password or other error. Identity error details says: " + result.ToString()); + return new RServiceResult(null, "نام کاربری و/یا رمز نادرست است."); } if (appUser.Status == RAppUserStatus.Inactive) { - return new RServiceResult(null, "User is disabled by an admin."); + return new RServiceResult(null, "نام کاربری شما غیرفعال شده است."); } RServiceResult securableItems = await GetUserSecurableItemsStatus(appUser.Id);