I've attempted to create a custom security handler per the kentico documentation.
I can see my method getting hit and step through the code but it doesn't seem to authenticate the user if an email is entered.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using CMS.SettingsProvider;
using CMS.Security;
using CMS.SiteProvider;
using CMS.MembershipProvider;
using CMS.GlobalHelper;
using System.Web.Security;
using CMS.CMSHelper;
using CMS.WebAnalytics;
[CustomSecurityEvents]
public partial class CMSModuleLoader
{
private class CustomSecurityEventsAttribute : CMSLoaderAttribute
{
public override void Init()
{
SecurityEvents.Authenticate.Execute += new EventHandler<AuthenticationEventArgs>(Authenticate_Execute);
}
void Authenticate_Execute(object sender, AuthenticationEventArgs e)
{
if (e.User != null)
return;
else
{
var membershipProvider = new CMSMembershipProvider();
if (ValidationHelper.IsEmail(e.UserName))
{
var username = membershipProvider.GetUserNameByEmail(e.UserName);
if (e.Password == membershipProvider.GetPassword(username, null))
{
e.User = UserInfoProvider.GetUserInfo(username);
}
}
}
}
}
}