Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions backend/src/unit-tests/validatePassword.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ describe('Password validation utils', () => {
it('Accepts correct password with symbols', () => {
expect(validatePassword('thisisav~!%ali&dpas$sword').isValid).toBeTruthy()
})
it('Accepts generated password symbols', () => {
expect(validatePassword('valid^password').isValid).toBeTruthy()
expect(validatePassword('valid?password').isValid).toBeTruthy()
})
it('Rejects invalid password with unsupported symbols in the middle', () => {
expect(validatePassword('thisisav~%a€li&dpas$sword').isValid).toBeFalsy()
})
Expand Down
2 changes: 1 addition & 1 deletion backend/src/utils/validatePassword.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export interface PasswordValidationResult {

export const validatePassword = (password: string): PasswordValidationResult => {
if (password.length < 8) return { isValid: false, error: 'Password must be at least 8 characters long' }
if (!/^[0-9A-Za-z$%&~!]+$/.test(password))
if (!/^[0-9A-Za-z^?$%&~!]+$/.test(password))
return {
isValid: false,
error: 'Password must only contain characters a-z, A-Z, 0-9 and ^?$%&~!',
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/hooks/usePasswordValidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const usePasswordValidation = () => {
return { isValid: false, error: requirements[0] }
}

if (!/^[0-9A-Za-z$%&~!]+$/.test(password)) {
if (!/^[0-9A-Za-z^?$%&~!]+$/.test(password)) {
return { isValid: false, error: requirements[1] }
}

Expand Down
Loading