overleaf/services/web/app/coffee/Features/Institutions/InstitutionsGetter.coffee
James Allen 49e19cad64 Merge pull request #1162 from sharelatex/ja-show-group-management
Add group and institution membership and management info to subscription dashboard

GitOrigin-RevId: 1aba5d5a20cd00ff5090811d0f66dc9c4944dd60
2018-11-20 11:03:56 +00:00

19 lines
878 B
CoffeeScript

UserGetter = require '../User/UserGetter'
UserMembershipHandler = require "../UserMembership/UserMembershipHandler"
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) ->) ->
UserMembershipHandler.getEntitiesByUser UserMembershipEntityConfigs.institution, user_id, callback