Skip to content

Commit

Permalink
Update password validation for alphanumeric
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelOyegbemi committed Jun 29, 2020
1 parent 150b54b commit 98d80eb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions app/database/models/credentials.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ module.exports = (sequelize, DataTypes) => {
throw new Error('Password length must be greater than or equal to 8 characters.');
}
},
alphanumeric(value) {
if (!/^(?=.*[0-9])(?=.*[a-zA-Z])(?=\S+$).*$/.test(value)) {
throw new Error('Password must contain at least one alphabet and one number');
}
},
},
},
userId: { type: DataTypes.UUID, allowNull: false },
Expand Down
2 changes: 1 addition & 1 deletion app/middlewares/refreshTokenOnExpire.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import jwtHelper from '../helpers/jwt';
import {getCookieDomain, getTokensFromRequest, setTokensToResponse} from '../helpers/auth';
import { getCookieDomain, getTokensFromRequest, setTokensToResponse } from '../helpers/auth';

/**
* @name refreshTokenOnExpire
Expand Down
2 changes: 1 addition & 1 deletion test/auth.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('Authentication tests', () => {
firstName: faker.name.firstName(),
lastName: faker.name.lastName(),
userType: faker.random.arrayElement(userTypes),
password: 'ade4samuel',
password: '1234567890dy&%$#',
};
/**
* @name authExpectations
Expand Down

0 comments on commit 98d80eb

Please sign in to comment.