mirror of
https://github.com/TriliumNext/Notes.git
synced 2026-04-25 14:18:53 -05:00
refactoring of password change and preparations for server side encryption
This commit is contained in:
@@ -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