Ejemplo n.º 1
0
        public AuthenticationResult GetAuthenticatedProfile(string username, string password)
        {
            var     authenticationResult = new AuthenticationResult();
            Profile profile = _profileRepository.FindSingle(x => string.Equals(x.Username, username, StringComparison.CurrentCultureIgnoreCase));

            if (profile != null)
            {
                authenticationResult.SetProfile(profile);
                if (!profile.IsEnabled)
                {
                    authenticationResult.SetuAuthenticationResultType(AuthenticationResultType.Disabled);
                    return(authenticationResult);
                }
                if (profile.FailedLoginCount >= Convert.ToInt32(Common.ErrorMessages.MAX_FAILED_LOGIN_ATTEMPTS))
                {
                    authenticationResult.SetuAuthenticationResultType(AuthenticationResultType.LockedOut);
                    return(authenticationResult);
                }
                if (IsAuthenticated(profile, password))
                {
                    authenticationResult.SetuAuthenticationResultType(AuthenticationResultType.Authenticated);
                }
            }
            return(authenticationResult);
        }