mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
22 lines
524 B
JavaScript
22 lines
524 B
JavaScript
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
|
|
}; |