overleaf/services/web/app/src/Features/Analytics/AnalyticsRegistrationSourceMiddleware.js

28 lines
432 B
JavaScript
Raw Normal View History

function setSource(source) {
return function (req, res, next) {
if (req.session) {
req.session.required_login_for = source
}
next()
}
}
function clearSource() {
return function (req, res, next) {
doClearSource(req.session)
next()
}
}
function doClearSource(session) {
if (session) {
delete session.required_login_for
}
}
module.exports = {
setSource,
clearSource,
doClearSource,
}