mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Added an ArgumentNullException sanity check to let devs know it’s not allowed here, and checked before calling the method. The standard validation pipeline does the rest as it is marked [Required]
This commit is contained in:
@@ -172,7 +172,7 @@ namespace Orchard.Core.Common.Handlers {
|
||||
var priorOwner = viewModel.Owner;
|
||||
context.Updater.TryUpdateModel(viewModel, "CommonAspect", null, null);
|
||||
|
||||
if (viewModel.Owner != priorOwner) {
|
||||
if (viewModel.Owner != null && viewModel.Owner != priorOwner) {
|
||||
var newOwner = _membershipService.GetUser(viewModel.Owner);
|
||||
if (newOwner == null) {
|
||||
context.Updater.AddModelError("CommonAspect.Owner", T("Invalid user name"));
|
||||
@@ -181,6 +181,7 @@ namespace Orchard.Core.Common.Handlers {
|
||||
instance.Owner = newOwner;
|
||||
}
|
||||
}
|
||||
|
||||
context.AddEditor(new TemplateViewModel(viewModel, "CommonAspect") { TemplateName = "Parts/Common.Owner", ZoneName = "primary", Position = "999" });
|
||||
}
|
||||
}
|
||||
|
@@ -44,6 +44,9 @@ namespace Orchard.Users.Services {
|
||||
}
|
||||
|
||||
public IUser GetUser(string username) {
|
||||
if(username == null) {
|
||||
throw new ArgumentNullException("username");
|
||||
}
|
||||
var userRecord = _userRepository.Get(x => x.NormalizedUserName == username.ToLower());
|
||||
if (userRecord == null) {
|
||||
return null;
|
||||
|
Reference in New Issue
Block a user