ILoginCompletedEvent
This interface is implemented by all events which fire after user logged in.
In the event handler you can access the following information:
- The username of the user who attempted to log in.
- The email of the user who attempted to log in.
- The ip address of the user who attempted to log in.
- The
LoginResult- information about the result of the login process. Possible results:Success- User was successfully registered as logged inUserLimitReached- The limit of maximum simultaneous logged in users is reachedUserNotFound- User not found in any providerUserLoggedFromDifferentIp- User is already logged in from different IP addressSessionExpired- Indicates that the user logical session has expiredUserLoggedOff- User have the authentication cookie but does not have logged in the database or user is already logged out.UserLoggedFormDifferentComputer- More than one users trying to login from the same IP but from different computers.Unknown- Invalid username or password specified.NeedAdminRights- User is not administrator to logout other usersUserAlreadyLoggedIn- User already is logged in. We need to ask the user to logout someone or himselfUserRevoked- User was revoked. The reason is that the user was deleted or user rights and role membership was changedSiteAccessNotAllowed- user is not allowed to access the current siteRejectedCustom- could be used for external (non-Sitefinity) validation.
Use the following code sample:
C#
using System;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.Security;
using Telerik.Sitefinity.Services;
using Telerik.Sitefinity.Web.Events;
namespace SitefinityWebApp
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
Bootstrapper.Bootstrapped += Bootstrapper_Bootstrapped;
}
private void Bootstrapper_Bootstrapped(object sender, EventArgs e)
{
EventHub.Subscribe<ILoginCompletedEvent>(LoginCompletedEventVerification);
}
private void LoginCompletedEventVerification(ILoginCompletedEvent evt)
{
if (evt.LoginResult == UserLoggingReason.Success)
{
if (evt.Username == "admin")
{
// admin user is successfully logged in.
}
}
}
}
}
Want to learn more?
Enhance your Sitefinity skills by enrolling in free training sessions. Become Sitefinity certified through Progress Education Community to strengthen your professional credentials.
Get started with Integration Hub | Sitefinity Cloud
This free lesson teaches administrators, marketers, and other business professionals how to use Sitefinity Integration Hub to create automated workflows between Sitefinity and other business systems.
Web Security for Sitefinity Administrators
This free lesson teaches administrators the basics about protecting your Sitefinity instance and your sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.
Foundations of Sitefinity ASP.NET Core Development
The free on-demand video course teaches developers how to use Sitefinity ASP.NET Core and take advantage of its decoupled architecture and modern development model.