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 in
    • UserLimitReached - The limit of maximum simultaneous logged in users is reached
    • UserNotFound - User not found in any provider
    • UserLoggedFromDifferentIp - User is already logged in from different IP address
    • SessionExpired - Indicates that the user logical session has expired
    • UserLoggedOff - 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 users
    • UserAlreadyLoggedIn - User already is logged in. We need to ask the user to logout someone or himself
    • UserRevoked - User was revoked. The reason is that the user was deleted or user rights and role membership was changed
    • SiteAccessNotAllowed - user is not allowed to access the current site
    • RejectedCustom - 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.
New to Sitefinity?