I'm using the standard Umbraco Login functionality (UmbLoginController), but now I got a request to include notifications when a member is locked out (send emails, display messages, etc).
Is there a way to hook into the login functionality or subscribe to an event of some sort so that I can include my logic?
I could of course implement my own Login controller, but I was hoping to avoid that.
I am actually trying to achieve the same thing. Does anyone have any recommendations on the best way to do this?
Been looking at creating a custom provider, however I can't seem to get that to work. Wasn't sure if there was a simpler way to hook into a login request.
Hi Alejandro
This is an interesting problem, I never thought of doing it before.
I think my article which shows you how to intercept member saving events will help you achieve what you need to here as the member must get saved when they are locked out for the property to be updated.
Thank you for your reply, That was a brilliant suggestion. I updated the code you had to access the UserService instead of the MemberService and it has done the trick.
For anyone else wanting to do the same thing, here is the code below:
using System;
using System.Collections.Generic;
using System.Linq;
using Umbraco.Core;
using Umbraco.Core.Events;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Membership;
using Umbraco.Core.Services;
using Umbraco.Web.Security.Providers;
namespace User.EventHandler
{
public class UserEventHandler : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
UserService.SavingUser += UserService_Saving;
}
private void UserService_Saving(IUserService sender, SaveEventArgs<IUser> e)
{
foreach (IUser user in e.SavedEntities)
{
//check to see if user is locked out
if (user.IsLockedOut)
{
//send email here
}
}
}
}
}
Extending Login functionality.
Hi everyone,
I'm using the standard Umbraco Login functionality (UmbLoginController), but now I got a request to include notifications when a member is locked out (send emails, display messages, etc).
Is there a way to hook into the login functionality or subscribe to an event of some sort so that I can include my logic?
I could of course implement my own Login controller, but I was hoping to avoid that.
Thanks!.
Hey Everyone,
I am actually trying to achieve the same thing. Does anyone have any recommendations on the best way to do this?
Been looking at creating a custom provider, however I can't seem to get that to work. Wasn't sure if there was a simpler way to hook into a login request.
Post I have been looking at can be found at this link https://our.umbraco.org/forum/developers/api-questions/30522-How-to-subscribe-to-backend-login-event-if-existing-else-alternative-solution?p=0#comment113339
Thanks for any help!
Hi Alejandro This is an interesting problem, I never thought of doing it before. I think my article which shows you how to intercept member saving events will help you achieve what you need to here as the member must get saved when they are locked out for the property to be updated.
http://www.codeshare.co.uk/blog/intercepting-content-and-member-save-events-in-umbraco/
Hi Paul,
Thank you for your reply, That was a brilliant suggestion. I updated the code you had to access the UserService instead of the MemberService and it has done the trick.
For anyone else wanting to do the same thing, here is the code below:
You're welcome Alejandro. I'm glad you got it working and my code was of use to you.
is working on a reply...