Merge pull request #15658 from overleaf/msm-team-invite-acceptance

[web] Team invite acceptance tests

GitOrigin-RevId: 755a4c483c93cee1ce4403c04db85fcbf4da06c3
This commit is contained in:
Miguel Serrano 2023-11-09 10:50:17 +01:00 committed by Copybot
parent 4dd2635c40
commit 7f347be7f3
3 changed files with 16 additions and 2 deletions

View file

@ -127,7 +127,7 @@ const SubscriptionLocator = {
async function hasSSOEnabled(subscription) { async function hasSSOEnabled(subscription) {
const ssoConfig = await SSOConfig.findById(subscription.ssoConfig).exec() const ssoConfig = await SSOConfig.findById(subscription.ssoConfig).exec()
return ssoConfig?.enabled return !!ssoConfig?.enabled
} }
SubscriptionLocator.promises = { SubscriptionLocator.promises = {

View file

@ -183,7 +183,7 @@ async function acceptInvite(req, res, next) {
subscription subscription
) )
res.status(204).json({ groupSSOActive }) res.json({ groupSSOActive })
} }
function revokeInvite(req, res, next) { function revokeInvite(req, res, next) {

View file

@ -4,6 +4,7 @@ const { promisify } = require('util')
const SubscriptionUpdater = require('../../../../app/src/Features/Subscription/SubscriptionUpdater') const SubscriptionUpdater = require('../../../../app/src/Features/Subscription/SubscriptionUpdater')
const ManagedUsersHandler = require('../../../../app/src/Features/Subscription/ManagedUsersHandler') const ManagedUsersHandler = require('../../../../app/src/Features/Subscription/ManagedUsersHandler')
const PermissionsManager = require('../../../../app/src/Features/Authorization/PermissionsManager') const PermissionsManager = require('../../../../app/src/Features/Authorization/PermissionsManager')
const SSOConfigManager = require('../../../../modules/managed-users/app/src/SSOConfigManager')
const SubscriptionModel = const SubscriptionModel =
require('../../../../app/src/models/Subscription').Subscription require('../../../../app/src/models/Subscription').Subscription
const DeletedSubscriptionModel = const DeletedSubscriptionModel =
@ -16,6 +17,7 @@ class Subscription {
this.groupPlan = options.groupPlan this.groupPlan = options.groupPlan
this.manager_ids = options.managerIds || [this.admin_id] this.manager_ids = options.managerIds || [this.admin_id]
this.member_ids = options.memberIds || [] this.member_ids = options.memberIds || []
this.membersLimit = options.membersLimit || 0
this.invited_emails = options.invitedEmails || [] this.invited_emails = options.invitedEmails || []
this.teamName = options.teamName this.teamName = options.teamName
this.teamInvites = options.teamInvites || [] this.teamInvites = options.teamInvites || []
@ -59,6 +61,18 @@ class Subscription {
) )
} }
setSSOConfig(ssoConfig, callback) {
this.get((err, subscription) => {
if (err) {
return callback(err)
}
SSOConfigManager.promises
.updateSubscriptionSSOConfig(subscription, ssoConfig)
.then(result => callback(null, result))
.catch(error => callback(error))
})
}
refreshUsersFeatures(callback) { refreshUsersFeatures(callback) {
SubscriptionUpdater.refreshUsersFeatures(this, callback) SubscriptionUpdater.refreshUsersFeatures(this, callback)
} }