fix: compute hash of the T&C text only

This commit is contained in:
André Sá 2022-04-27 16:00:08 +01:00
parent c5e7627afb
commit 028c8c3b13

View file

@ -30,19 +30,18 @@ const SECRET_FIELDS = [
* JSON.stringify isn't necessarily deterministic so this function may compute
* different hashes for the same object.
*/
const md5hash = obj =>
const md5hash = text =>
crypto
.createHash('MD5')
.update(JSON.stringify(obj))
.update(text)
.digest('hex')
const addTermsHash = configs => {
configs = _.omit('termsConditions_hash', configs)
const terms = getTermsConditions(configs)
const terms = _.omit(['hash'], getTermsConditions(configs))
return _.isEmpty(terms) ?
configs :
_.flow(
_.omit(['hash']),
_.get('text'),
md5hash,
hash => _.set('hash', hash, terms),
setTermsConditions,