overleaf/services/web/app/coffee/Features/Institutions/InstitutionsGetter.coffee
Timothée Alby 6232854ff7 Remove User Memberships on Deletion (#1688)
Remove User Memberships on Deletion

GitOrigin-RevId: d6e6a4cc01e31288f660c2fd36a0cee174ee5dd1
2019-04-23 14:34:40 +00:00

19 lines
881 B
CoffeeScript

UserGetter = require '../User/UserGetter'
UserMembershipsHandler = require "../UserMembership/UserMembershipsHandler"
UserMembershipEntityConfigs = require "../UserMembership/UserMembershipEntityConfigs"
logger = require 'logger-sharelatex'
module.exports = InstitutionsGetter =
getConfirmedInstitutions: (userId, callback = (error, institutions) ->) ->
UserGetter.getUserFullEmails userId, (error, emailsData) ->
return callback error if error?
confirmedInstitutions = emailsData.filter (emailData) ->
emailData.confirmedAt? and emailData.affiliation?.institution?.confirmed
.map (emailData) ->
emailData.affiliation?.institution
callback(null, confirmedInstitutions)
getManagedInstitutions: (user_id, callback = (error, managedInstitutions) ->) ->
UserMembershipsHandler.getEntitiesByUser UserMembershipEntityConfigs.institution, user_id, callback