refactoring of password change and preparations for server side encryption

This commit is contained in:
azivner
2017-11-09 23:25:23 -05:00
parent 433982e7bc
commit 8f1eedfe0d
7 changed files with 116 additions and 49 deletions

View File

@@ -0,0 +1,22 @@
const utils = require('./utils');
function setDataKey(req, decryptedDataKey) {
req.session.decryptedDataKey = decryptedDataKey;
req.session.protectedSessionId = utils.randomSecureToken(32);
return req.session.protectedSessionId;
}
function getDataKey(req, protectedSessionId) {
if (protectedSessionId && req.session.protectedSessionId === protectedSessionId) {
return req.session.decryptedDataKey;
}
else {
return null;
}
}
module.exports = {
setDataKey,
getDataKey
};