Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Richard Hamilton 79 posts 169 karma points
    Sep 01, 2016 @ 16:33
    Richard Hamilton
    0

    How to log valid User Logins on version 7.3 and after

    I am using the following code to check when a user logs in: public class MyPasswordChecker : IBackOfficeUserPasswordChecker { public Task

            //get this user by username to obtain the new Id
            var userService = ApplicationContext.Current.Services.UserService;
            var uUser = userService.GetByUsername(user.UserName);
            var result = Task.FromResult(BackOfficeUserPasswordCheckerResult.FallbackToDefaultChecker);
    
            //check for LOCKED out
            if (uUser.IsLockedOut)
            {
                UserLoggingService.Log(uUser.Id, LogEntryAction.LogInFailed, "User Locked Out");
            }
            else
            {
                UserLoggingService.Log(uUser.Id, LogEntryAction.LogIn, "Attempted Login");
            }        
    
            return result;
        }
    }
    

    I want to log when a user attempts to login but is LOCKED OUT - which my code here can handle.

    Also I need to log when a user SUCCESFULLY LOGS IN - but at the stage I only know they are attempting to log in.

    I also want to return a friendly message to the user if they are LOCKED OUT so they know to contact admin and not keep trying to login.

    It's hard to find any documentation on anything after 7.3 as I know it was changed to IDENTITY.

    I am now using Umbraco 7.5 for this project.

  • Tom 119 posts 447 karma points
    Mar 13, 2017 @ 13:16
    Tom
    0

    Hi, Did you find a solution?

Please Sign in or register to post replies

Write your reply to:

Draft