mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-03 06:09:02 +02:00
d902505ac9
[web] send explicit content type in responses GitOrigin-RevId: d5aeaba57a7d2fc053fbf5adc2299fb46e435341
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.json({ contacts: [] })
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
apply(webRouter) {
|
|
webRouter.get(
|
|
'/user/contacts',
|
|
contactsAuthenticationMiddleware(),
|
|
ContactController.getContacts
|
|
)
|
|
},
|
|
}
|