Exemplo n.º 1
0
 public IActionResult ExcludeCommonPasswordsPolicy(Policy policy, int projectId,
                                                   ExcludeCommonPasswordsConfiguration policySettings)
 {
     try
     {
         savePolicyToProjectFactory.Create().Invoke(projectId, policy, policySettings);
         Alert(AlertType.Success, "Policy saved correctly.");
         return(RedirectToAction("GetById", "Projects", new { id = projectId }));
     }
     catch (Exception ex)
     {
         Alert(AlertType.Warning, ex.Message);
         return(View("ErrorPage"));
     }
 }
Exemplo n.º 2
0
        public static bool ExcludeCommonPasswords(ExcludeCommonPasswordsConfiguration config, string password)
        {
            using (var stream = File.OpenText(@"common_passwords_list.txt"))
            {
                while (!stream.EndOfStream)
                {
                    var commonPassword = stream.ReadLine();
                    if (password == commonPassword)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }