mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Check the subscription is in a group plan before adding new members
This commit is contained in:
parent
c4250e601e
commit
5159f6f33d
2 changed files with 15 additions and 3 deletions
|
@ -124,6 +124,11 @@ removeInviteFromTeam = (subscriptionId, email, callback) ->
|
|||
|
||||
|
||||
checkIfInviteIsPossible = (subscription, email, callback = (error, possible, reason) -> ) ->
|
||||
unless subscription.groupPlan
|
||||
logger.log {subscriptionId: subscription.id},
|
||||
"can not add members to a subscription that is not in a group plan"
|
||||
return callback(null, false, wrongPlan: true)
|
||||
|
||||
if LimitationsManager.teamHasReachedMemberLimit(subscription)
|
||||
logger.log {subscriptionId: subscription.id}, "team has reached member limit"
|
||||
return callback(null, false, limitReached: true)
|
||||
|
|
|
@ -26,9 +26,10 @@ describe "TeamInvitesHandler", ->
|
|||
@subscription = {
|
||||
id: "55153a8014829a865bbf700d",
|
||||
admin_id: @manager.id,
|
||||
member_ids: []
|
||||
teamInvites: [ @teamInvite ]
|
||||
save: sinon.stub().yields(null)
|
||||
groupPlan: true,
|
||||
member_ids: [],
|
||||
teamInvites: [ @teamInvite ],
|
||||
save: sinon.stub().yields(null),
|
||||
}
|
||||
|
||||
@SubscriptionLocator = {
|
||||
|
@ -234,6 +235,12 @@ describe "TeamInvitesHandler", ->
|
|||
expect(err).to.deep.equal(limitReached: true)
|
||||
done()
|
||||
|
||||
it "doesn't create an invite if the subscription is not in a group plan", (done) ->
|
||||
@subscription.groupPlan = false
|
||||
@TeamInvitesHandler.createInvite @manager.id, "John.Snow@nightwatch.com", (err, invite) =>
|
||||
expect(err).to.deep.equal(wrongPlan: true)
|
||||
done()
|
||||
|
||||
it "doesn't create an invite if the user is already part of the team", (done) ->
|
||||
member = {
|
||||
id: "1a2b",
|
||||
|
|
Loading…
Reference in a new issue