mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
#19760: Propagating the suppression of IEnumerable<> and loops for IUserEventHandlers
Work Item: 19760
This commit is contained in:

committed by
Nicholas Mayne

parent
4b4f673c36
commit
8e6a7486ce
@@ -25,7 +25,7 @@ namespace Orchard.Users.Controllers {
|
||||
public class AdminController : Controller, IUpdateModel {
|
||||
private readonly IMembershipService _membershipService;
|
||||
private readonly IUserService _userService;
|
||||
private readonly IEnumerable<IUserEventHandler> _userEventHandlers;
|
||||
private readonly IUserEventHandler _userEventHandlers;
|
||||
private readonly ISiteService _siteService;
|
||||
|
||||
public AdminController(
|
||||
@@ -33,7 +33,7 @@ namespace Orchard.Users.Controllers {
|
||||
IMembershipService membershipService,
|
||||
IUserService userService,
|
||||
IShapeFactory shapeFactory,
|
||||
IEnumerable<IUserEventHandler> userEventHandlers,
|
||||
IUserEventHandler userEventHandlers,
|
||||
ISiteService siteService) {
|
||||
Services = services;
|
||||
_membershipService = membershipService;
|
||||
@@ -318,9 +318,7 @@ namespace Orchard.Users.Controllers {
|
||||
if ( user != null ) {
|
||||
user.As<UserPart>().RegistrationStatus = UserStatus.Approved;
|
||||
Services.Notifier.Information(T("User {0} approved", user.UserName));
|
||||
foreach (var userEventHandler in _userEventHandlers) {
|
||||
userEventHandler.Approved(user);
|
||||
}
|
||||
_userEventHandlers.Approved(user);
|
||||
}
|
||||
|
||||
return RedirectToAction("Index");
|
||||
|
@@ -20,7 +20,7 @@ namespace Orchard.Users.Services {
|
||||
public class MembershipService : IMembershipService {
|
||||
private readonly IOrchardServices _orchardServices;
|
||||
private readonly IMessageService _messageService;
|
||||
private readonly IEnumerable<IUserEventHandler> _userEventHandlers;
|
||||
private readonly IUserEventHandler _userEventHandlers;
|
||||
private readonly IEncryptionService _encryptionService;
|
||||
private readonly IShapeFactory _shapeFactory;
|
||||
private readonly IShapeDisplay _shapeDisplay;
|
||||
@@ -28,7 +28,7 @@ namespace Orchard.Users.Services {
|
||||
public MembershipService(
|
||||
IOrchardServices orchardServices,
|
||||
IMessageService messageService,
|
||||
IEnumerable<IUserEventHandler> userEventHandlers,
|
||||
IUserEventHandler userEventHandlers,
|
||||
IClock clock,
|
||||
IEncryptionService encryptionService,
|
||||
IShapeFactory shapeFactory,
|
||||
@@ -76,9 +76,7 @@ namespace Orchard.Users.Services {
|
||||
}
|
||||
|
||||
var userContext = new UserContext {User = user, Cancel = false, UserParameters = createUserParams};
|
||||
foreach(var userEventHandler in _userEventHandlers) {
|
||||
userEventHandler.Creating(userContext);
|
||||
}
|
||||
_userEventHandlers.Creating(userContext);
|
||||
|
||||
if(userContext.Cancel) {
|
||||
return null;
|
||||
@@ -86,11 +84,9 @@ namespace Orchard.Users.Services {
|
||||
|
||||
_orchardServices.ContentManager.Create(user);
|
||||
|
||||
foreach ( var userEventHandler in _userEventHandlers ) {
|
||||
userEventHandler.Created(userContext);
|
||||
if (user.RegistrationStatus == UserStatus.Approved) {
|
||||
userEventHandler.Approved(user);
|
||||
}
|
||||
_userEventHandlers.Created(userContext);
|
||||
if (user.RegistrationStatus == UserStatus.Approved) {
|
||||
_userEventHandlers.Approved(user);
|
||||
}
|
||||
|
||||
if ( registrationSettings != null
|
||||
|
Reference in New Issue
Block a user