Merge pull request #3064 from overleaf/ta-manage-multiple-groups
Allow Users to Manage Multiple Groups GitOrigin-RevId: c918da0114cdd1d679223f69d81159b4c2608874
This commit is contained in:
@@ -43,9 +43,12 @@ module.exports = {
|
||||
},
|
||||
|
||||
removeSelfFromGroup(req, res, next) {
|
||||
const adminUserId = req.query.admin_user_id
|
||||
const subscriptionId = req.query.subscriptionId
|
||||
const userToRemove_id = AuthenticationController.getLoggedInUserId(req)
|
||||
return getManagedSubscription(adminUserId, function(error, subscription) {
|
||||
return SubscriptionLocator.getSubscription(subscriptionId, function(
|
||||
error,
|
||||
subscription
|
||||
) {
|
||||
if (error != null) {
|
||||
return next(error)
|
||||
}
|
||||
@@ -56,7 +59,7 @@ module.exports = {
|
||||
function(err) {
|
||||
if (err != null) {
|
||||
logger.err(
|
||||
{ err, userToRemove_id, adminUserId },
|
||||
{ err, userToRemove_id, subscriptionId },
|
||||
'error removing self from group'
|
||||
)
|
||||
return res.sendStatus(500)
|
||||
@@ -65,35 +68,5 @@ module.exports = {
|
||||
}
|
||||
)
|
||||
})
|
||||
},
|
||||
|
||||
// legacy route
|
||||
redirectToSubscriptionGroupAdminPage(req, res, next) {
|
||||
const user_id = AuthenticationController.getLoggedInUserId(req)
|
||||
return getManagedSubscription(user_id, function(error, subscription) {
|
||||
if (error != null) {
|
||||
return next(error)
|
||||
}
|
||||
if (!(subscription != null ? subscription.groupPlan : undefined)) {
|
||||
return res.redirect('/user/subscription')
|
||||
}
|
||||
return res.redirect(`/manage/groups/${subscription._id}/members`)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var getManagedSubscription = (managerId, callback) =>
|
||||
SubscriptionLocator.findManagedSubscription(managerId, function(
|
||||
err,
|
||||
subscription
|
||||
) {
|
||||
if (err) {
|
||||
return callback(err)
|
||||
} else if (!subscription) {
|
||||
return callback(
|
||||
new Error(`No subscription found managed by user ${managerId}`)
|
||||
)
|
||||
}
|
||||
|
||||
return callback(null, subscription)
|
||||
})
|
||||
|
||||
@@ -42,10 +42,6 @@ const SubscriptionLocator = {
|
||||
)
|
||||
},
|
||||
|
||||
findManagedSubscription(managerId, callback) {
|
||||
return Subscription.findOne({ manager_ids: managerId }, callback)
|
||||
},
|
||||
|
||||
getManagedGroupSubscriptions(user_or_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function(error, managedSubscriptions) {}
|
||||
@@ -121,9 +117,6 @@ SubscriptionLocator.promises = {
|
||||
getUserIndividualSubscription: promisify(
|
||||
SubscriptionLocator.getUserIndividualSubscription
|
||||
),
|
||||
findManagedSubscription: promisify(
|
||||
SubscriptionLocator.findManagedSubscription
|
||||
),
|
||||
getManagedGroupSubscriptions: promisify(
|
||||
SubscriptionLocator.getManagedGroupSubscriptions
|
||||
),
|
||||
|
||||
@@ -47,11 +47,6 @@ module.exports = {
|
||||
SubscriptionController.canceledSubscription
|
||||
)
|
||||
|
||||
webRouter.get(
|
||||
'/subscription/group',
|
||||
AuthenticationController.requireLogin(),
|
||||
SubscriptionGroupController.redirectToSubscriptionGroupAdminPage
|
||||
)
|
||||
webRouter.delete(
|
||||
'/subscription/group/user',
|
||||
AuthenticationController.requireLogin(),
|
||||
|
||||
Reference in New Issue
Block a user