mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 09:09:36 +02:00
Extract functions from AuthenticationController to SessionManager GitOrigin-RevId: 86870ce03a762e1a837dcf493759e8851e759883
29 lines
769 B
JavaScript
29 lines
769 B
JavaScript
const AuthenticationController = require('../Authentication/AuthenticationController')
|
|
const SessionManager = require('../Authentication/SessionManager')
|
|
const ContactController = require('./ContactController')
|
|
const Settings = require('@overleaf/settings')
|
|
|
|
function contactsAuthenticationMiddleware() {
|
|
if (!Settings.allowAnonymousReadAndWriteSharing) {
|
|
return AuthenticationController.requireLogin()
|
|
} else {
|
|
return (req, res, next) => {
|
|
if (SessionManager.isUserLoggedIn(req.session)) {
|
|
next()
|
|
} else {
|
|
res.send({ contacts: [] })
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
apply(webRouter) {
|
|
webRouter.get(
|
|
'/user/contacts',
|
|
contactsAuthenticationMiddleware(),
|
|
ContactController.getContacts
|
|
)
|
|
},
|
|
}
|