Skip to content

Commit 456ca1d

Browse files
committed
496: Update password validation -- Numbers, letters, certain symbols
1 parent 06c99dd commit 456ca1d

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/client/src/pages/UserManagement/Validations.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export const DISALLOWED_WORDS = [
44
'cat',
55
'dog',
66
'password',
7-
7+
'paws',
88
]
99

1010
export const buildNameValidation = () => {
@@ -33,12 +33,10 @@ export const buildRoleValidation = () => {
3333

3434
export const buildPasswordValidation = (username) => {
3535
return Yup.string()
36-
.trim()
37-
38-
36+
.required("Password is required")
3937
.test(
4038
"no-disallowed-words",
41-
"Password cannot include 'dog', 'cat', 'password', or your username",
39+
"Password cannot include 'dog', 'cat', 'password', 'paws', or your username",
4240
(value, context) => {
4341
if (!value) {
4442
return true;
@@ -48,6 +46,7 @@ export const buildPasswordValidation = (username) => {
4846
const lowercaseUsername = username || context.parent.username.toLowerCase()
4947
return [...DISALLOWED_WORDS, lowercaseUsername].every((word) => !lowercasePassword.includes(word))
5048
})
49+
.matches(/^[a-zA-Z0-9!@#$%^*]+$/, "Password can only contain numbers, letters, and the following symbols: !@#$%^*")
5150
.min(12, "Password must contain at least 12 letters")
5251
.max(36, "Password must be 36 characters or less")
5352
}

0 commit comments

Comments
 (0)