private IUser ValidateLogOn(string userNameOrEmail, string password)
        {
            bool validate = true;

            if (String.IsNullOrEmpty(userNameOrEmail))
            {
                ModelState.AddModelError("userNameOrEmail", T("You must specify a username or e-mail."));
                validate = false;
            }
            if (String.IsNullOrEmpty(password))
            {
                ModelState.AddModelError("password", T("You must specify a password."));
                validate = false;
            }

            if (_limitLoginService.IsAccountLocked(userNameOrEmail))
            {
                ModelState.AddModelError("password", T("Your account has been locked due to repeated failed login attempts, please try back later."));
                validate = false;
            }
            if (!validate)
            {
                return(null);
            }

            var user = _membershipService.ValidateUser(userNameOrEmail, password);

            if (user == null)
            {
                _userEventHandler.LogInFailed(userNameOrEmail, password);
                ModelState.AddModelError("_FORM", T("The username or e-mail or password provided is incorrect."));
            }

            return(user);
        }
Esempio n. 2
0
        private IUser ValidateLogOn(string userNameOrEmail, string password)
        {
            bool validate = true;

            if (String.IsNullOrEmpty(userNameOrEmail))
            {
                ModelState.AddModelError("userNameOrEmail", T("You must specify a username or e-mail."));
                validate = false;
            }
            if (String.IsNullOrEmpty(password))
            {
                ModelState.AddModelError("password", T("You must specify a password."));
                validate = false;
            }

            if (!validate)
            {
                return(null);
            }

            var user = _membershipService.ValidateUser(userNameOrEmail, password);

            if (user == null)
            {
                _userEventHandler.LogInFailed(userNameOrEmail, password);
                ModelState.AddModelError("_FORM", T("The username or e-mail or password provided is incorrect."));
            }

            return(user);
        }
Esempio n. 3
0
        private IUser ValidateLogOn(string userNameOrEmail, string password)
        {
            bool validate = true;

            if (string.IsNullOrEmpty(userNameOrEmail))
            {
                ModelState.AddModelError("userNameOrEmail", T("You must specify a username or e-mail."));
                validate = false;
            }
            if (string.IsNullOrEmpty(password))
            {
                ModelState.AddModelError("password", T("You must specify a password."));
                validate = false;
            }

            if (!validate)
            {
                return(null);
            }

            var validationResult = _membershipService.ValidateUser(userNameOrEmail, password, out List <LocalizedString> validationErrors);

            if (validationResult == null)
            {
                _userEventHandler.LogInFailed(userNameOrEmail, password);
            }

            foreach (var error in validationErrors)
            {
                ModelState.AddModelError("_FORM", error);
            }

            return(validationResult);
        }