Adding a LoggingIn method to IUserEventHandler

This commit is contained in:
Nicholas Mayne
2014-05-17 09:46:12 +01:00
parent 14faf47bfa
commit 6c4b830866
4 changed files with 24 additions and 0 deletions

View File

@@ -51,6 +51,17 @@ namespace Orchard.Users.Activities {
} }
} }
[OrchardFeature("Orchard.Users.Workflows")]
public class UserLoggingInActivity : UserActivity {
public override string Name {
get { return "UserLoggingIn"; }
}
public override LocalizedString Description {
get { return T("User is logging in."); }
}
}
[OrchardFeature("Orchard.Users.Workflows")] [OrchardFeature("Orchard.Users.Workflows")]
public class UserLoggedInActivity : UserActivity { public class UserLoggedInActivity : UserActivity {
public override string Name { public override string Name {

View File

@@ -78,6 +78,8 @@ namespace Orchard.Users.Controllers {
[SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings",
Justification = "Needs to take same parameter type as Controller.Redirect()")] Justification = "Needs to take same parameter type as Controller.Redirect()")]
public ActionResult LogOn(string userNameOrEmail, string password, string returnUrl, bool rememberMe = false) { public ActionResult LogOn(string userNameOrEmail, string password, string returnUrl, bool rememberMe = false) {
_userEventHandler.LoggingIn(userNameOrEmail, password);
var user = ValidateLogOn(userNameOrEmail, password); var user = ValidateLogOn(userNameOrEmail, password);
if (!ModelState.IsValid) { if (!ModelState.IsValid) {
var shape = _orchardServices.New.LogOn().Title(T("Log On").Text); var shape = _orchardServices.New.LogOn().Title(T("Log On").Text);

View File

@@ -13,6 +13,11 @@ namespace Orchard.Users.Events {
/// </summary> /// </summary>
void Created(UserContext context); void Created(UserContext context);
/// <summary>
/// Called before a user has logged in
/// </summary>
void LoggingIn(string userNameOrEmail, string password);
/// <summary> /// <summary>
/// Called after a user has logged in /// Called after a user has logged in
/// </summary> /// </summary>

View File

@@ -24,6 +24,12 @@ namespace Orchard.Users.Handlers {
() => new Dictionary<string, object> {{"User", context}}); () => new Dictionary<string, object> {{"User", context}});
} }
public void LoggingIn(string userNameOrEmail, string password) {
_workflowManager.TriggerEvent("UserLoggingIn",
null,
() => new Dictionary<string, object>{{"UserNameOrEmail", userNameOrEmail}, {"Password", password}});
}
public void LoggedIn(Security.IUser user) { public void LoggedIn(Security.IUser user) {
_workflowManager.TriggerEvent("UserLoggedIn", _workflowManager.TriggerEvent("UserLoggedIn",
user, user,