mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-10 22:50:46 +02:00
c6c62088cc
GitOrigin-RevId: 4e9d3176b4b5a5504afc102e569a27d7788864a3
29 lines
757 B
JavaScript
29 lines
757 B
JavaScript
import AuthenticationController from '../Authentication/AuthenticationController.js'
|
|
import SessionManager from '../Authentication/SessionManager.js'
|
|
import ContactController from './ContactController.mjs'
|
|
import Settings from '@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: [] })
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
export default {
|
|
apply(webRouter) {
|
|
webRouter.get(
|
|
'/user/contacts',
|
|
contactsAuthenticationMiddleware(),
|
|
ContactController.getContacts
|
|
)
|
|
},
|
|
}
|