mirror of https://github.com/TriliumNext/Notes
got rid of request context and related refactorings
parent
50ff5da947
commit
e206269457
@ -1,34 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
|
|
||||||
const protected_session = require('./protected_session');
|
|
||||||
|
|
||||||
module.exports = function(req) {
|
|
||||||
const sourceId = req.headers.source_id;
|
|
||||||
|
|
||||||
function isProtectedSessionAvailable() {
|
|
||||||
return protected_session.isProtectedSessionAvailable(req);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getDataKey() {
|
|
||||||
if (!isProtectedSessionAvailable()) {
|
|
||||||
throw new Error("Protected session is not available");
|
|
||||||
}
|
|
||||||
|
|
||||||
return protected_session.getDataKey(req);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getDataKeyOrNull() {
|
|
||||||
if (!isProtectedSessionAvailable()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return protected_session.getDataKey(req);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
sourceId,
|
|
||||||
isProtectedSessionAvailable,
|
|
||||||
getDataKey,
|
|
||||||
getDataKeyOrNull
|
|
||||||
};
|
|
||||||
};
|
|
||||||
Loading…
Reference in New Issue