Skip to content

Commit

Permalink
Merge pull request #1654 from auth0/fix/empty-password-submit
Browse files Browse the repository at this point in the history
Prevent form submit when password is empty
  • Loading branch information
luisrudge authored May 23, 2019
2 parents 94da80e + e3b42dc commit b21499d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/__tests__/field/password.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ describe('field/password', () => {
passwordField = require('field/password');
});
describe('validatePassword()', () => {
it(`returns false when there is no password`, () => {
const value = passwordField.validatePassword('');
expect(value).toBe(false);
});
it(`returns true when there is no policy`, () => {
const value = passwordField.validatePassword('the-password');
expect(value).toBe(true);
Expand Down
3 changes: 3 additions & 0 deletions src/field/password.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import PasswordPolicy from 'password-sheriff/lib/policy';
import { setField } from './index';

export function validatePassword(password, policy) {
if (!password) {
return false;
}
if (!policy) {
return true;
}
Expand Down

0 comments on commit b21499d

Please sign in to comment.