diff --git a/.editorconfig b/.editorconfig
index b61deab..3124ec3 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -8,6 +8,9 @@ roslynator_accessibility_modifiers = explicit
roslynator_enum_has_flag_style = operator
roslynator_object_creation_type_style = implicit_when_type_is_obvious
+# S2094: Remove this empty class, write its code or make it an "interface".
+dotnet_diagnostic.S2094.severity = suggestion
+
# CA5395: Action method xyz needs to specify the HTTP request kind explicitly
dotnet_diagnostic.CA5395.severity = suggestion
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 6838241..c662835 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -1,21 +1,21 @@
-
+
-
+
-
+
-
-
+
+
-
+
@@ -35,7 +35,7 @@
-
+
\ No newline at end of file
diff --git a/src/ASPNETCoreIdentitySample/Areas/Identity/Controllers/ForgotPasswordController.cs b/src/ASPNETCoreIdentitySample/Areas/Identity/Controllers/ForgotPasswordController.cs
index e353211..a04ca77 100644
--- a/src/ASPNETCoreIdentitySample/Areas/Identity/Controllers/ForgotPasswordController.cs
+++ b/src/ASPNETCoreIdentitySample/Areas/Identity/Controllers/ForgotPasswordController.cs
@@ -12,12 +12,12 @@
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
-using Language = DNTCaptcha.Core.Language;
namespace ASPNETCoreIdentitySample.Areas.Identity.Controllers;
-[Area(AreaConstants.IdentityArea), AllowAnonymous,
- BreadCrumb(Title = "بازیابی کلمهی عبور", UseDefaultRouteUrl = true, Order = 0)]
+[Area(AreaConstants.IdentityArea)]
+[AllowAnonymous]
+[BreadCrumb(Title = "بازیابی کلمهی عبور", UseDefaultRouteUrl = true, Order = 0)]
public class ForgotPasswordController : Controller
{
private readonly IEmailSender _emailSender;
@@ -38,19 +38,14 @@ public ForgotPasswordController(
}
[BreadCrumb(Title = "تائید کلمهی عبور فراموش شده", Order = 1)]
- public IActionResult ForgotPasswordConfirmation()
- {
- return View();
- }
+ public IActionResult ForgotPasswordConfirmation() => View();
[BreadCrumb(Title = "ایندکس", Order = 1)]
- public IActionResult Index()
- {
- return View();
- }
+ public IActionResult Index() => View();
- [HttpPost, ValidateAntiForgeryToken, ValidateDNTCaptcha(CaptchaGeneratorLanguage = Language.Persian,
- CaptchaGeneratorDisplayMode = DisplayMode.SumOfTwoNumbers)]
+ [HttpPost]
+ [ValidateAntiForgeryToken]
+ [ValidateDNTCaptcha]
public async Task Index(ForgotPasswordViewModel model)
{
if (model is null)
@@ -68,16 +63,16 @@ public async Task Index(ForgotPasswordViewModel model)
var code = await _userManager.GeneratePasswordResetTokenAsync(user);
await _emailSender.SendEmailAsync(
- model.Email,
- "بازیابی کلمهی عبور",
- "~/Areas/Identity/Views/EmailTemplates/_PasswordReset.cshtml",
- new PasswordResetViewModel
- {
- UserId = user.Id,
- Token = code,
- EmailSignature = _siteOptions.Value.Smtp.FromName,
- MessageDateTime = DateTime.UtcNow.ToLongPersianDateTimeString()
- })
+ model.Email,
+ "بازیابی کلمهی عبور",
+ "~/Areas/Identity/Views/EmailTemplates/_PasswordReset.cshtml",
+ new PasswordResetViewModel
+ {
+ UserId = user.Id,
+ Token = code,
+ EmailSignature = _siteOptions.Value.Smtp.FromName,
+ MessageDateTime = DateTime.UtcNow.ToLongPersianDateTimeString(),
+ })
;
return View("ForgotPasswordConfirmation");
@@ -89,7 +84,10 @@ await _emailSender.SendEmailAsync(
///
/// For [Remote] validation
///
- [AjaxOnly, HttpPost, ValidateAntiForgeryToken, ResponseCache(Location = ResponseCacheLocation.None, NoStore = true)]
+ [AjaxOnly]
+ [HttpPost]
+ [ValidateAntiForgeryToken]
+ [ResponseCache(Location = ResponseCacheLocation.None, NoStore = true)]
public async Task ValidatePassword(string password, string email)
{
var user = await _userManager.FindByEmailAsync(email);
@@ -99,17 +97,15 @@ public async Task ValidatePassword(string password, string email)
}
var result = await _passwordValidator.ValidateAsync(
- (UserManager)_userManager, user, password);
+ (UserManager)_userManager, user, password);
return Json(result.Succeeded ? "true" : result.DumpErrors(true));
}
[BreadCrumb(Title = "تغییر کلمهی عبور", Order = 1)]
- public IActionResult ResetPassword(string code = null)
- {
- return code == null ? View("Error") : View();
- }
+ public IActionResult ResetPassword(string code = null) => code == null ? View("Error") : View();
- [HttpPost, ValidateAntiForgeryToken]
+ [HttpPost]
+ [ValidateAntiForgeryToken]
public async Task ResetPassword(ResetPasswordViewModel model)
{
if (model is null)
@@ -144,8 +140,5 @@ public async Task ResetPassword(ResetPasswordViewModel model)
}
[BreadCrumb(Title = "تائیدیه تغییر کلمهی عبور", Order = 1)]
- public IActionResult ResetPasswordConfirmation()
- {
- return View();
- }
+ public IActionResult ResetPasswordConfirmation() => View();
}
\ No newline at end of file
diff --git a/src/ASPNETCoreIdentitySample/Areas/Identity/Controllers/LoginController.cs b/src/ASPNETCoreIdentitySample/Areas/Identity/Controllers/LoginController.cs
index 00cd788..e2acec3 100644
--- a/src/ASPNETCoreIdentitySample/Areas/Identity/Controllers/LoginController.cs
+++ b/src/ASPNETCoreIdentitySample/Areas/Identity/Controllers/LoginController.cs
@@ -10,8 +10,9 @@
namespace ASPNETCoreIdentitySample.Areas.Identity.Controllers;
-[Area(AreaConstants.IdentityArea), AllowAnonymous,
- BreadCrumb(Title = "ورود به سیستم", UseDefaultRouteUrl = true, Order = 0)]
+[Area(AreaConstants.IdentityArea)]
+[AllowAnonymous]
+[BreadCrumb(Title = "ورود به سیستم", UseDefaultRouteUrl = true, Order = 0)]
public class LoginController : Controller
{
private readonly IApplicationSignInManager _signInManager;
@@ -28,15 +29,17 @@ public LoginController(
_siteOptions = siteOptions ?? throw new ArgumentNullException(nameof(siteOptions));
}
- [BreadCrumb(Title = "ایندکس", Order = 1), NoBrowserCache]
+ [BreadCrumb(Title = "ایندکس", Order = 1)]
+ [NoBrowserCache]
public IActionResult Index(string returnUrl = null)
{
ViewData["ReturnUrl"] = returnUrl;
return View();
}
- [HttpPost, ValidateAntiForgeryToken, ValidateDNTCaptcha(CaptchaGeneratorLanguage = Language.Persian,
- CaptchaGeneratorDisplayMode = DisplayMode.SumOfTwoNumbers)]
+ [HttpPost]
+ [ValidateAntiForgeryToken]
+ [ValidateDNTCaptcha]
public async Task Index(LoginViewModel model, string returnUrl = null)
{
if (model is null)
@@ -68,10 +71,10 @@ public async Task Index(LoginViewModel model, string returnUrl =
}
var result = await _signInManager.PasswordSignInAsync(
- model.Username,
- model.Password,
- model.RememberMe,
- true);
+ model.Username,
+ model.Password,
+ model.RememberMe,
+ true);
if (result.Succeeded)
{
if (Url.IsLocalUrl(returnUrl))
@@ -85,9 +88,9 @@ public async Task Index(LoginViewModel model, string returnUrl =
if (result.RequiresTwoFactor)
{
return RedirectToAction(
- nameof(TwoFactorController.SendCode),
- "TwoFactor",
- new { ReturnUrl = returnUrl, model.RememberMe });
+ nameof(TwoFactorController.SendCode),
+ "TwoFactor",
+ new { ReturnUrl = returnUrl, model.RememberMe });
}
if (result.IsLockedOut)
@@ -112,8 +115,8 @@ public async Task Index(LoginViewModel model, string returnUrl =
public async Task LogOff()
{
var user = User.Identity is { IsAuthenticated: true }
- ? await _userManager.FindByNameAsync(User.Identity.Name)
- : null;
+ ? await _userManager.FindByNameAsync(User.Identity.Name)
+ : null;
await _signInManager.SignOutAsync();
if (user != null)
{
diff --git a/src/ASPNETCoreIdentitySample/Areas/Identity/Controllers/RegisterController.cs b/src/ASPNETCoreIdentitySample/Areas/Identity/Controllers/RegisterController.cs
index e6917a9..a41734a 100644
--- a/src/ASPNETCoreIdentitySample/Areas/Identity/Controllers/RegisterController.cs
+++ b/src/ASPNETCoreIdentitySample/Areas/Identity/Controllers/RegisterController.cs
@@ -91,8 +91,7 @@ public IActionResult Index()
return View();
}
- [HttpPost, ValidateAntiForgeryToken, ValidateDNTCaptcha(CaptchaGeneratorLanguage = Language.Persian,
- CaptchaGeneratorDisplayMode = DisplayMode.SumOfTwoNumbers)]
+ [HttpPost, ValidateAntiForgeryToken, ValidateDNTCaptcha]
public async Task Index(RegisterViewModel model)
{
if (model is null)