diff --git a/src/OrchardCore.Modules/OrchardCore.Users/Controllers/AccountController.cs b/src/OrchardCore.Modules/OrchardCore.Users/Controllers/AccountController.cs index 3e88f66dc4e..221e2402247 100644 --- a/src/OrchardCore.Modules/OrchardCore.Users/Controllers/AccountController.cs +++ b/src/OrchardCore.Modules/OrchardCore.Users/Controllers/AccountController.cs @@ -312,7 +312,7 @@ private async Task ExternalLoginSignInAsync(IUser user, ExternalLo } catch (Exception ex) { - _logger.LogError(ex, "{externalLoginHandler} - IExternalLoginHandler.UpdateRoles threw an exception", item.GetType()); + _logger.LogError(ex, "{ExternalLoginHandler}.UpdateRoles threw an exception", item.GetType()); } } diff --git a/src/OrchardCore.Modules/OrchardCore.Users/Controllers/AdminController.cs b/src/OrchardCore.Modules/OrchardCore.Users/Controllers/AdminController.cs index 59e92d28eef..ff6cb9297c1 100644 --- a/src/OrchardCore.Modules/OrchardCore.Users/Controllers/AdminController.cs +++ b/src/OrchardCore.Modules/OrchardCore.Users/Controllers/AdminController.cs @@ -499,7 +499,7 @@ public async Task EditPassword(string id) return Forbid(); } - var model = new ResetPasswordViewModel { Identifier = user.UserName }; + var model = new ResetPasswordViewModel { UsernameOrEmail = user.UserName }; return View(model); } @@ -507,7 +507,7 @@ public async Task EditPassword(string id) [HttpPost] public async Task EditPassword(ResetPasswordViewModel model) { - if (await _userService.GetUserAsync(model.Identifier) is not User user) + if (await _userService.GetUserAsync(model.UsernameOrEmail) is not User user) { return NotFound(); } @@ -521,7 +521,7 @@ public async Task EditPassword(ResetPasswordViewModel model) { var token = await _userManager.GeneratePasswordResetTokenAsync(user); - if (await _userService.ResetPasswordAsync(model.Identifier, token, model.NewPassword, ModelState.AddModelError)) + if (await _userService.ResetPasswordAsync(model.UsernameOrEmail, token, model.NewPassword, ModelState.AddModelError)) { await _notifier.SuccessAsync(H["Password updated correctly."]); diff --git a/src/OrchardCore.Modules/OrchardCore.Users/Controllers/ResetPasswordController.cs b/src/OrchardCore.Modules/OrchardCore.Users/Controllers/ResetPasswordController.cs index 298ab953f3e..ce825aea29f 100644 --- a/src/OrchardCore.Modules/OrchardCore.Users/Controllers/ResetPasswordController.cs +++ b/src/OrchardCore.Modules/OrchardCore.Users/Controllers/ResetPasswordController.cs @@ -93,7 +93,7 @@ public async Task ForgotPasswordPOST() if (ModelState.IsValid) { - var user = await _userService.GetForgotPasswordUserAsync(model.Identifier) as User; + var user = await _userService.GetForgotPasswordUserAsync(model.UsernameOrEmail) as User; if (user == null || await MustValidateEmailAsync(user)) { // returns to confirmation page anyway: we don't want to let scrapers know if a username or an email exist @@ -166,7 +166,7 @@ public async Task ResetPasswordPOST() { var token = Encoding.UTF8.GetString(Convert.FromBase64String(model.ResetToken)); - if (await _userService.ResetPasswordAsync(model.Identifier, token, model.NewPassword, ModelState.AddModelError)) + if (await _userService.ResetPasswordAsync(model.UsernameOrEmail, token, model.NewPassword, ModelState.AddModelError)) { return RedirectToAction(nameof(ResetPasswordConfirmation)); } diff --git a/src/OrchardCore.Modules/OrchardCore.Users/Drivers/ForgotPasswordFormDisplayDriver.cs b/src/OrchardCore.Modules/OrchardCore.Users/Drivers/ForgotPasswordFormDisplayDriver.cs index cc087b1efb7..c6b6bd6c5e6 100644 --- a/src/OrchardCore.Modules/OrchardCore.Users/Drivers/ForgotPasswordFormDisplayDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Users/Drivers/ForgotPasswordFormDisplayDriver.cs @@ -13,7 +13,7 @@ public override IDisplayResult Edit(ForgotPasswordForm model) { return Initialize("ForgotPasswordFormIdentifier", vm => { - vm.Identifier = model.Identifier; + vm.UsernameOrEmail = model.UsernameOrEmail; }).Location("Content"); } @@ -23,7 +23,7 @@ public override async Task UpdateAsync(ForgotPasswordForm model, await updater.TryUpdateModelAsync(viewModel, Prefix); - model.Identifier = viewModel.Identifier; + model.UsernameOrEmail = viewModel.UsernameOrEmail; return Edit(model); } diff --git a/src/OrchardCore.Modules/OrchardCore.Users/Drivers/ResetPasswordFormDisplayDriver.cs b/src/OrchardCore.Modules/OrchardCore.Users/Drivers/ResetPasswordFormDisplayDriver.cs index d188e00c29b..8b5e2b1723c 100644 --- a/src/OrchardCore.Modules/OrchardCore.Users/Drivers/ResetPasswordFormDisplayDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Users/Drivers/ResetPasswordFormDisplayDriver.cs @@ -13,7 +13,7 @@ public override IDisplayResult Edit(ResetPasswordForm model) { return Initialize("ResetPasswordFormIdentifier", vm => { - vm.Identifier = model.Identifier; + vm.UsernameOrEmail = model.UsernameOrEmail; vm.NewPassword = model.NewPassword; vm.ResetToken = model.ResetToken; }).Location("Content"); @@ -25,7 +25,7 @@ public override async Task UpdateAsync(ResetPasswordForm model, await updater.TryUpdateModelAsync(vm, Prefix); - model.Identifier = vm.Identifier; + model.UsernameOrEmail = vm.UsernameOrEmail; model.NewPassword = vm.NewPassword; model.ResetToken = vm.ResetToken; diff --git a/src/OrchardCore.Modules/OrchardCore.Users/ViewModels/ForgotPasswordViewModel.cs b/src/OrchardCore.Modules/OrchardCore.Users/ViewModels/ForgotPasswordViewModel.cs index 2fac0702b57..0bb15c54d1a 100644 --- a/src/OrchardCore.Modules/OrchardCore.Users/ViewModels/ForgotPasswordViewModel.cs +++ b/src/OrchardCore.Modules/OrchardCore.Users/ViewModels/ForgotPasswordViewModel.cs @@ -5,11 +5,11 @@ namespace OrchardCore.Users.ViewModels { public class ForgotPasswordViewModel { - [Obsolete("Email property is no longer used and will be removed in future releases. Instead use Identifier.")] + [Obsolete("Email property is no longer used and will be removed in future releases. Instead use UsernameOrEmail.")] [Email.EmailAddress(ErrorMessage = "Invalid Email.")] public string Email { get; set; } [Required(ErrorMessage = "Username or email address is required.")] - public string Identifier { get; set; } + public string UsernameOrEmail { get; set; } } } diff --git a/src/OrchardCore.Modules/OrchardCore.Users/ViewModels/ResetPasswordViewModel.cs b/src/OrchardCore.Modules/OrchardCore.Users/ViewModels/ResetPasswordViewModel.cs index 2e30d1bfb5d..4c81b332c3e 100644 --- a/src/OrchardCore.Modules/OrchardCore.Users/ViewModels/ResetPasswordViewModel.cs +++ b/src/OrchardCore.Modules/OrchardCore.Users/ViewModels/ResetPasswordViewModel.cs @@ -5,12 +5,12 @@ namespace OrchardCore.Users.ViewModels { public class ResetPasswordViewModel { - [Obsolete("Email property is no longer used and will be removed in future releases. Instead use Identifier.")] + [Obsolete("Email property is no longer used and will be removed in future releases. Instead use UsernameOrEmail.")] [Email.EmailAddress(ErrorMessage = "Invalid Email.")] public string Email { get; set; } [Required(ErrorMessage = "Username or email address is required.")] - public string Identifier { get; set; } + public string UsernameOrEmail { get; set; } [Required(ErrorMessage = "New password is required.")] [DataType(DataType.Password)] diff --git a/src/OrchardCore.Modules/OrchardCore.Users/Views/Admin/EditPassword.cshtml b/src/OrchardCore.Modules/OrchardCore.Users/Views/Admin/EditPassword.cshtml index fffe05f3d5b..353636bb537 100644 --- a/src/OrchardCore.Modules/OrchardCore.Users/Views/Admin/EditPassword.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Users/Views/Admin/EditPassword.cshtml @@ -4,7 +4,7 @@
- +
diff --git a/src/OrchardCore.Modules/OrchardCore.Users/Views/ForgotPasswordFormIdentifier.cshtml b/src/OrchardCore.Modules/OrchardCore.Users/Views/ForgotPasswordFormIdentifier.cshtml index 4a1388eba44..a4a2be2b2a2 100644 --- a/src/OrchardCore.Modules/OrchardCore.Users/Views/ForgotPasswordFormIdentifier.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Users/Views/ForgotPasswordFormIdentifier.cshtml @@ -1,6 +1,6 @@ @model ForgotPasswordViewModel
- - + +
diff --git a/src/OrchardCore.Modules/OrchardCore.Users/Views/ResetPasswordFormIdentifier.cshtml b/src/OrchardCore.Modules/OrchardCore.Users/Views/ResetPasswordFormIdentifier.cshtml index d2fa7d15272..32be249eda9 100644 --- a/src/OrchardCore.Modules/OrchardCore.Users/Views/ResetPasswordFormIdentifier.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Users/Views/ResetPasswordFormIdentifier.cshtml @@ -3,9 +3,9 @@
- - - + + +
diff --git a/src/OrchardCore/OrchardCore.Users.Abstractions/Services/IUserService.cs b/src/OrchardCore/OrchardCore.Users.Abstractions/Services/IUserService.cs index 8cbf8a7bb20..0d668f59e59 100644 --- a/src/OrchardCore/OrchardCore.Users.Abstractions/Services/IUserService.cs +++ b/src/OrchardCore/OrchardCore.Users.Abstractions/Services/IUserService.cs @@ -12,11 +12,11 @@ public interface IUserService /// /// Authenticates the user credentials. /// - /// The username or email address. + /// The username or email address. /// The user password. /// The error reported in case failure happened during the authentication process. /// A that represents an authenticated user. - Task AuthenticateAsync(string identifier, string password, Action reportError); + Task AuthenticateAsync(string usernameOrEmail, string password, Action reportError); /// /// Creates a user. @@ -56,9 +56,9 @@ public interface IUserService /// /// Gets the user with a specified username or email address. /// - /// The username or email address. + /// The username or email address. /// The represents the retrieved user. - Task GetUserAsync(string identifier); + Task GetUserAsync(string usernameOrEmail); /// /// Gets the user with a specified ID. @@ -77,12 +77,12 @@ public interface IUserService /// /// Resets the user password. /// - /// The username or email address. + /// The username or email address. /// The token used to reset the password. /// The new password. /// The error reported in case failure happened during the reset process. /// Returns true if the password reset, otherwise false. - Task ResetPasswordAsync(string identifier, string resetToken, string newPassword, Action reportError); + Task ResetPasswordAsync(string usernameOrEmail, string resetToken, string newPassword, Action reportError); /// /// Creates a for a given user. diff --git a/src/OrchardCore/OrchardCore.Users.Core/Models/ForgotPasswordForm.cs b/src/OrchardCore/OrchardCore.Users.Core/Models/ForgotPasswordForm.cs index cfe629664bb..3618e5116dc 100644 --- a/src/OrchardCore/OrchardCore.Users.Core/Models/ForgotPasswordForm.cs +++ b/src/OrchardCore/OrchardCore.Users.Core/Models/ForgotPasswordForm.cs @@ -4,5 +4,5 @@ namespace OrchardCore.Users.Models; public class ForgotPasswordForm : Entity { - public string Identifier { get; set; } + public string UsernameOrEmail { get; set; } } diff --git a/src/OrchardCore/OrchardCore.Users.Core/Models/ResetPasswordForm.cs b/src/OrchardCore/OrchardCore.Users.Core/Models/ResetPasswordForm.cs index d5dfc31a784..a8306592926 100644 --- a/src/OrchardCore/OrchardCore.Users.Core/Models/ResetPasswordForm.cs +++ b/src/OrchardCore/OrchardCore.Users.Core/Models/ResetPasswordForm.cs @@ -4,7 +4,7 @@ namespace OrchardCore.Users.Models; public class ResetPasswordForm : Entity { - public string Identifier { get; set; } + public string UsernameOrEmail { get; set; } public string NewPassword { get; set; } diff --git a/src/OrchardCore/OrchardCore.Users.Core/Services/UserService.cs b/src/OrchardCore/OrchardCore.Users.Core/Services/UserService.cs index f05c7eb8bbc..2e40d3110f1 100644 --- a/src/OrchardCore/OrchardCore.Users.Core/Services/UserService.cs +++ b/src/OrchardCore/OrchardCore.Users.Core/Services/UserService.cs @@ -45,7 +45,7 @@ public UserService( _logger = logger; } - public async Task AuthenticateAsync(string identifier, string password, Action reportError) + public async Task AuthenticateAsync(string usernameOrEmail, string password, Action reportError) { var disableLocalLogin = (await _siteService.GetSiteSettingsAsync()).As().DisableLocalLogin; @@ -55,7 +55,7 @@ public async Task AuthenticateAsync(string identifier, string password, A return null; } - if (string.IsNullOrWhiteSpace(identifier)) + if (string.IsNullOrWhiteSpace(usernameOrEmail)) { reportError("Username", S["A user name is required."]); return null; @@ -67,7 +67,7 @@ public async Task AuthenticateAsync(string identifier, string password, A return null; } - var user = await GetUserAsync(identifier); + var user = await GetUserAsync(usernameOrEmail); if (user == null) { reportError(string.Empty, S["The specified username/password couple is invalid."]); @@ -184,12 +184,12 @@ public async Task GetForgotPasswordUserAsync(string userId) return user; } - public async Task ResetPasswordAsync(string identifier, string resetToken, string newPassword, Action reportError) + public async Task ResetPasswordAsync(string usernameOrEmail, string resetToken, string newPassword, Action reportError) { var result = true; - if (string.IsNullOrWhiteSpace(identifier)) + if (string.IsNullOrWhiteSpace(usernameOrEmail)) { - reportError(nameof(ResetPasswordForm.Identifier), S["A username or email address is required."]); + reportError(nameof(ResetPasswordForm.UsernameOrEmail), S["A username or email address is required."]); result = false; } @@ -210,7 +210,7 @@ public async Task ResetPasswordAsync(string identifier, string resetToken, return result; } - var user = await GetUserAsync(identifier) as User; + var user = await GetUserAsync(usernameOrEmail) as User; if (user == null) { @@ -244,19 +244,20 @@ public Task CreatePrincipalAsync(IUser user) return _signInManager.CreateUserPrincipalAsync(user); } - public async Task GetUserAsync(string identifier) + public async Task GetUserAsync(string usernameOrEmail) { - var user = await _userManager.FindByNameAsync(identifier); + var user = await _userManager.FindByNameAsync(usernameOrEmail); if (user is null && _identityOptions.User.RequireUniqueEmail) { - user = await _userManager.FindByEmailAsync(identifier); + user = await _userManager.FindByEmailAsync(usernameOrEmail); } return user; } - public Task GetUserByUniqueIdAsync(string userIdentifier) => _userManager.FindByIdAsync(userIdentifier); + public Task GetUserByUniqueIdAsync(string userId) + => _userManager.FindByIdAsync(userId); public void ProcessValidationErrors(IEnumerable errors, User user, Action reportError) { diff --git a/src/docs/releases/1.9.0.md b/src/docs/releases/1.9.0.md index 618ed226032..cf158fd7cfc 100644 --- a/src/docs/releases/1.9.0.md +++ b/src/docs/releases/1.9.0.md @@ -163,7 +163,7 @@ public class ReCaptchaResetPasswordFormDisplayDriver : DisplayDriver`. For example, the ReCaptcha shape is injected using the following driver: