From ecaa98ef6e71cdcb4f27773472a31fa70a3802d6 Mon Sep 17 00:00:00 2001 From: Convly Date: Fri, 8 Oct 2021 11:10:43 +0200 Subject: [PATCH] Don't check if it has already been hashed --- .../processing/attributes/password.js | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/packages/core/strapi/lib/services/entity-service/processing/attributes/password.js b/packages/core/strapi/lib/services/entity-service/processing/attributes/password.js index 91c80838ea..2cbed68b56 100644 --- a/packages/core/strapi/lib/services/entity-service/processing/attributes/password.js +++ b/packages/core/strapi/lib/services/entity-service/processing/attributes/password.js @@ -3,24 +3,10 @@ const bcrypt = require('bcrypt'); const { AttributeProcessor } = require('./processor'); -/** Explanation for the isHashed RegExp - * Starts with $2b$ => /\$2b\$ - * Then is followed by 2 digits and a $ sign. => \d{2}\$ - * Ends with 53 alphanumerics characters (plus . and /) => [./a-z-A-Z0-9]{53}/ - */ -const bcryptHashRegExp = /\$2b\$\d{2}\$[./a-z-A-Z0-9]{53}/; - const transformActions = ['create', 'update']; -const isHashed = value => bcryptHashRegExp.test(value); - class PasswordProcessor extends AttributeProcessor { transform(value, context) { - // Don't update the value if it has already been hashed - if (isHashed(value)) { - return value; - } - const { action } = context; if (!transformActions.includes(action)) {