diff --git a/ghost/security/lib/tokens.js b/ghost/security/lib/tokens.js index d7f687c81e..ae2f1d28e6 100644 --- a/ghost/security/lib/tokens.js +++ b/ghost/security/lib/tokens.js @@ -2,7 +2,25 @@ const crypto = require('crypto'); -exports.resetToken = { +module.exports.generateHash = function generateHash(options) { + options = options || {}; + + const hash = crypto.createHash('sha256'), + expires = options.expires, + email = options.email, + secret = options.secret; + + let text = ''; + + hash.update(String(expires)); + hash.update(email.toLocaleLowerCase()); + hash.update(String(secret)); + + text += [expires, email, hash.digest('base64')].join('|'); + return new Buffer(text).toString('base64'); +}; + +module.exports.resetToken = { generateHash: function generateHash(options) { options = options || {};