Merge pull request #30835 from overleaf/ii-domain-capture-invite-token

[web] Create invite token when domain capture is disabled

GitOrigin-RevId: 193b5b8567c3b593c98f432568b47cc4e9e17339
This commit is contained in:
Jessica Lawshe
2026-01-23 09:06:24 +00:00
committed by Copybot
parent a116175698
commit 59dc237e53
4 changed files with 80 additions and 2 deletions
@@ -1,3 +1,4 @@
import crypto from 'node:crypto'
import settings from '@overleaf/settings'
import logger from '@overleaf/logger'
import OError from '@overleaf/o-error'
@@ -280,6 +281,11 @@ async function resendInvite(req, res, next) {
)?.[0]
acceptInviteUrl = `${settings.siteUrl}${samlInitPath}`
} else {
if (!currentInvite.token) {
currentInvite.token = crypto.randomBytes(32).toString('hex')
currentInvite.domainCapture = false
await subscription.save()
}
acceptInviteUrl = `${settings.siteUrl}/subscription/invites/${currentInvite.token}/`
}
@@ -233,8 +233,11 @@ async function _createInvite(subscription, email, inviter, auditLog) {
let invite = subscription.teamInvites.find(invite => invite.email === email)
if (invite) {
invite = invite.toObject()
invite.sentAt = new Date()
if (!invite.token && !domainCaptureEnabled) {
invite.token = crypto.randomBytes(32).toString('hex')
invite.domainCapture = false
}
} else {
if (domainCaptureEnabled) {
invite = {