mirror of
https://git.unistra.fr/aius/root/ldap-overleaf-sl.git
synced 2025-05-04 19:55:26 +02:00
Adapted Contact Controller to work with Sharelatex 3.3.2
This commit is contained in:
parent
682d15d62e
commit
a0e70e4f1f
2 changed files with 20 additions and 21 deletions
|
@ -1,4 +1,4 @@
|
||||||
FROM sharelatex/sharelatex:3.1.0
|
FROM sharelatex/sharelatex:3.3.2
|
||||||
# FROM sharelatex/sharelatex:latest
|
# FROM sharelatex/sharelatex:latest
|
||||||
# latest might not be tested
|
# latest might not be tested
|
||||||
# e.g. the AuthenticationManager.js script had to be adapted after versions 2.3.1
|
# e.g. the AuthenticationManager.js script had to be adapted after versions 2.3.1
|
||||||
|
|
|
@ -17,13 +17,12 @@ const AuthenticationController = require('../Authentication/AuthenticationContro
|
||||||
const SessionManager = require('../Authentication/SessionManager')
|
const SessionManager = require('../Authentication/SessionManager')
|
||||||
const ContactManager = require('./ContactManager')
|
const ContactManager = require('./ContactManager')
|
||||||
const UserGetter = require('../User/UserGetter')
|
const UserGetter = require('../User/UserGetter')
|
||||||
const logger = require('logger-sharelatex')
|
const logger = require('@overleaf/logger')
|
||||||
const Modules = require('../../infrastructure/Modules')
|
const Modules = require('../../infrastructure/Modules')
|
||||||
const { Client } = require('ldapts');
|
const { Client } = require('ldapts');
|
||||||
|
|
||||||
module.exports = ContactsController = {
|
module.exports = ContactsController = {
|
||||||
getContacts(req, res, next) {
|
getContacts(req, res, next) {
|
||||||
// const user_id = AuthenticationController.getLoggedInUserId(req)
|
|
||||||
const user_id = SessionManager.getLoggedInUserId(req.session)
|
const user_id = SessionManager.getLoggedInUserId(req.session)
|
||||||
return ContactManager.getContactIds(
|
return ContactManager.getContactIds(
|
||||||
user_id,
|
user_id,
|
||||||
|
@ -45,25 +44,25 @@ module.exports = ContactsController = {
|
||||||
return next(error)
|
return next(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserGetter.getUsers may not preserve order so put them back in order
|
// UserGetter.getUsers may not preserve order so put them back in order
|
||||||
const positions = {}
|
const positions = {}
|
||||||
for (let i = 0; i < contact_ids.length; i++) {
|
for (let i = 0; i < contact_ids.length; i++) {
|
||||||
const contact_id = contact_ids[i]
|
const contact_id = contact_ids[i]
|
||||||
positions[contact_id] = i
|
positions[contact_id] = i
|
||||||
}
|
}
|
||||||
|
contacts.sort(
|
||||||
|
(a, b) =>
|
||||||
|
positions[a._id != null ? a._id.toString() : undefined] -
|
||||||
|
positions[b._id != null ? b._id.toString() : undefined]
|
||||||
|
)
|
||||||
|
|
||||||
contacts.sort(
|
// Don't count holding accounts to discourage users from repeating mistakes (mistyped or wrong emails, etc)
|
||||||
(a, b) =>
|
contacts = contacts.filter(c => !c.holdingAccount)
|
||||||
positions[a._id != null ? a._id.toString() : undefined] -
|
ContactsController.getLdapContacts(contacts).then((ldapcontacts) => {
|
||||||
positions[b._id != null ? b._id.toString() : undefined]
|
contacts.push(ldapcontacts)
|
||||||
)
|
contacts = contacts.map(ContactsController._formatContact)
|
||||||
|
|
||||||
// Don't count holding accounts to discourage users from repeating mistakes (mistyped or wrong emails, etc)
|
return Modules.hooks.fire('getContacts', user_id, contacts, function(
|
||||||
contacts = contacts.filter(c => !c.holdingAccount)
|
|
||||||
ContactsController.getLdapContacts(contacts).then((ldapcontacts) => {
|
|
||||||
contacts.push(ldapcontacts)
|
|
||||||
contacts = contacts.map(ContactsController._formatContact)
|
|
||||||
return Modules.hooks.fire('getContacts', user_id, contacts, function(
|
|
||||||
error,
|
error,
|
||||||
additional_contacts
|
additional_contacts
|
||||||
) {
|
) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue