Added unit tests for models.Invite.add

no issue

- replaced token creation by `lib.common.security`
- added unit tests for adding invites
- allow a different invite status for internal access
This commit is contained in:
kirrg001 2018-04-25 11:56:45 +02:00
parent 5d1a4418bd
commit a0ee411e6e

View File

@ -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 || {};