mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-01-23 13:22:08 +08:00
SantiagoIT's contribution to add an approved event to the user event handler, with a slight modification to where it's raised in the membership service on user creation.
--HG-- branch : contributions
This commit is contained in:
@@ -4,13 +4,13 @@ using System.Text.RegularExpressions;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Core.Common.Models;
|
||||
using Orchard.Core.Contents.Controllers;
|
||||
using Orchard.Core.Settings.Models;
|
||||
using Orchard.DisplayManagement;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Security;
|
||||
using Orchard.UI.Notify;
|
||||
using Orchard.Users.Events;
|
||||
using Orchard.Users.Models;
|
||||
using Orchard.Users.Services;
|
||||
using Orchard.Users.ViewModels;
|
||||
@@ -24,6 +24,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 ISiteService _siteService;
|
||||
|
||||
public AdminController(
|
||||
@@ -31,10 +32,12 @@ namespace Orchard.Users.Controllers {
|
||||
IMembershipService membershipService,
|
||||
IUserService userService,
|
||||
IShapeFactory shapeFactory,
|
||||
IEnumerable<IUserEventHandler> userEventHandlers,
|
||||
ISiteService siteService) {
|
||||
Services = services;
|
||||
_membershipService = membershipService;
|
||||
_userService = userService;
|
||||
_userEventHandlers = userEventHandlers;
|
||||
_siteService = siteService;
|
||||
|
||||
T = NullLocalizer.Instance;
|
||||
@@ -311,6 +314,9 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
return RedirectToAction("Index");
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Orchard.Users.Events {
|
||||
void LoggedIn(IUser user);
|
||||
|
||||
/// <summary>
|
||||
/// Called when a user explicitly logs out (as opposed to one whos session cookie simply expires)
|
||||
/// Called when a user explicitly logs out (as opposed to one whose session cookie simply expires)
|
||||
/// </summary>
|
||||
void LoggedOut(IUser user);
|
||||
|
||||
@@ -42,6 +42,11 @@ namespace Orchard.Users.Events {
|
||||
/// Called after a user has confirmed their email address
|
||||
/// </summary>
|
||||
void ConfirmedEmail(IUser user);
|
||||
|
||||
/// <summary>
|
||||
/// Called after a user has been approved
|
||||
/// </summary>
|
||||
void Approved(IUser user);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -76,6 +76,9 @@ namespace Orchard.Users.Services {
|
||||
|
||||
foreach ( var userEventHandler in _userEventHandlers ) {
|
||||
userEventHandler.Created(userContext);
|
||||
if (user.RegistrationStatus == UserStatus.Approved) {
|
||||
userEventHandler.Approved(user);
|
||||
}
|
||||
}
|
||||
|
||||
if ( registrationSettings != null && registrationSettings.UsersAreModerated && registrationSettings.NotifyModeration && !createUserParams.IsApproved ) {
|
||||
|
||||
Reference in New Issue
Block a user