Added: comments and general clean-up
This commit is contained in:
parent
605e05fad1
commit
3cd3d97139
2 changed files with 7 additions and 4 deletions
|
@ -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 (
|
||||
|
|
|
@ -4,8 +4,10 @@ namespace back_end.Services;
|
|||
|
||||
public class PasswordService : IPasswordService
|
||||
{
|
||||
private List<string> _commonPasswords = new List<string>();
|
||||
private readonly List<string> _commonPasswords = new List<string>();
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue