/// <summary> /// Determines whether a new UserLogin with the specified parameters would be valid /// </summary> /// <param name="userName">Name of the user.</param> /// <param name="password">The password.</param> /// <param name="passwordConfirm">The password confirm.</param> /// <param name="errorTitle">The error title.</param> /// <param name="errorMessage">The error message.</param> /// <returns> /// <c>true</c> if [is valid new user login] [the specified user name]; otherwise, <c>false</c>. /// </returns> public static bool IsValidNewUserLogin(string userName, string password, string passwordConfirm, out string errorTitle, out string errorMessage) { errorTitle = null; errorMessage = null; if (string.IsNullOrWhiteSpace(userName) || string.IsNullOrWhiteSpace(password)) { errorTitle = "Missing Information"; errorMessage = "A username and password are required when saving an account"; return(false); } if (new UserLoginService(new RockContext()).Exists(userName)) { errorTitle = "Invalid Username"; errorMessage = "The selected Username is already being used. Please select a different Username"; return(false); } if (!UserLoginService.IsPasswordValid(password)) { errorTitle = string.Empty; errorMessage = UserLoginService.FriendlyPasswordRules(); return(false); } if (passwordConfirm != password) { errorTitle = "Invalid Password"; errorMessage = "The password and password confirmation do not match"; return(false); } return(true); }