diff --git a/Client/src/pages/index.tsx b/Client/src/pages/index.tsx index ce41d9a..a71f3ad 100644 --- a/Client/src/pages/index.tsx +++ b/Client/src/pages/index.tsx @@ -32,6 +32,7 @@ export default function Home() { }; const validatePasswordLength = (password: string) => { + // check if all of the characters between the start and end of the password add to 7-14 characters const regex = new RegExp('^.{7,14}$'); return regex.test(password); }; @@ -78,7 +79,6 @@ export default function Home() { setPasswordChangeStatus(false); } } - // need to handle the response back } return ( diff --git a/Server/BackEnd/Services/PasswordService.cs b/Server/BackEnd/Services/PasswordService.cs index f387976..23b736b 100644 --- a/Server/BackEnd/Services/PasswordService.cs +++ b/Server/BackEnd/Services/PasswordService.cs @@ -4,8 +4,10 @@ namespace back_end.Services; public class PasswordService : IPasswordService { - private List _commonPasswords = new List(); + private readonly List _commonPasswords = new List(); + // load common passwords on start up to save us from having to re-load the file over and over + // if the list would change, then this is a bad idea public void LoadCommonPasswords(string filepath) { if (_commonPasswords.Count != 0) return; @@ -15,7 +17,7 @@ public class PasswordService : IPasswordService } catch (Exception e) { - throw new Exception("Error loading common passwords.", e); + throw new Exception("Error loading common passwords: ", e); } } @@ -28,7 +30,8 @@ public class PasswordService : IPasswordService public bool IsPasswordCommon(string? password) { - if (password == null) return true; + if (password == null) return true; + // since .Contains tries to checks the index, password123! and 123!password will return true return _commonPasswords.Contains(password); } } \ No newline at end of file