-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(account): introduce local password validation identical to dhis2-…
…core
- Loading branch information
1 parent
f4043f5
commit 6cff458
Showing
2 changed files
with
19 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Atleast one digit | ||
const oneDigit = /^(?=.*\d)/; | ||
|
||
// Atleast one uppercase character | ||
const oneUpperCase = /^(?=.*[A-Z])/; | ||
|
||
// Atleast one special character | ||
// Using this regex to match all non-alphanumeric characters to match server-side implementation | ||
// https://github.com/dhis2/dhis2-core/blob/master/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/SpecialCharacterValidationRule.java#L39 | ||
const oneSpecialCharacter = /[^a-zA-Z0-9]/; | ||
|
||
export default function isValidPassword(value) { | ||
if (!value) { | ||
return true; | ||
} | ||
return oneDigit.test(value) && oneUpperCase.test(value) && oneSpecialCharacter.test(value) && value.length > 7 && value.length < 36; | ||
} | ||
isValidPassword.message = 'invalid_password'; |