mirror of
https://github.com/zadam/trilium.git
synced 2025-11-02 03:16:11 +01:00
refactoring of password change and preparations for server side encryption
This commit is contained in:
22
services/protected_session.js
Normal file
22
services/protected_session.js
Normal 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
|
||||
};
|
||||
Reference in New Issue
Block a user