Merge pull request #32816 from overleaf/jel-domain-captured-by-group

[web] Check `domainCapturedByGroup` on domain instead of `group.domainCaptureEnabled` only for project/dash redirect

GitOrigin-RevId: a6389da9c943327e5941eaa24eb274106526f80b
This commit is contained in:
Jessica Lawshe
2026-05-06 09:41:04 -05:00
committed by Copybot
parent d3f5738158
commit fc4e17d30f
4 changed files with 87 additions and 0 deletions

View File

@@ -319,6 +319,7 @@ const decorateFullEmails = (
entitlement: cachedEntitlement,
portal,
group,
domainCapturedByGroup,
} = affiliation
const lastDayToReconfirm = _lastDayToReconfirm(emailData, institution)
let { last_day_to_reconfirm: cachedLastDayToReconfirm } = affiliation
@@ -346,6 +347,7 @@ const decorateFullEmails = (
department,
licence,
portal,
domainCapturedByGroup,
}
if (group) {
emailData.affiliation.group = group

View File

@@ -557,6 +557,27 @@ describe('ProjectListController', function () {
await ctx.ProjectListController.projectListPage(ctx.req, ctx.res)
})
it('should not redirect to domain capture page when no domain capture groups found', async function (ctx) {
ctx.Features.hasFeature.withArgs('saas').returns(true)
ctx.SplitTestHandler.promises.getAssignment
.withArgs(ctx.req, ctx.res, 'domain-capture-redirect')
.resolves({ variant: 'enabled' })
ctx.Modules.promises.hooks.fire
.withArgs('findDomainCaptureGroupsUserCouldBePartOf', ctx.user._id)
.resolves([[]])
let redirectCalled = false
ctx.res.redirect = () => {
redirectCalled = true
}
let redirectTo = ''
ctx.res.render = (pageName, opts) => {
redirectTo = pageName
}
await ctx.ProjectListController.projectListPage(ctx.req, ctx.res)
expect(redirectCalled).to.be.false
expect(redirectTo).to.equal('project/list-react')
})
describe('when user linked to SSO', function () {
const linkedEmail = 'picard@starfleet.com'
const universityName = 'Starfleet'

View File

@@ -253,6 +253,7 @@ describe('UserGetter', function () {
cachedPastReconfirmDate: false,
pastReconfirmDate: false,
portal: undefined,
domainCapturedByGroup: undefined,
},
},
{
@@ -265,6 +266,68 @@ describe('UserGetter', function () {
])
})
it('should include domainCapturedByGroup in merged affiliation', async function (ctx) {
ctx.UserGetter.promises.getUser = sinon.stub().resolves(ctx.fakeUser)
const affiliationsData = [
{
email: 'email1@foo.bar',
role: null,
cached_confirmed_at: null,
cached_reconfirmed_at: null,
department: null,
entitlement: false,
inferred: false,
licence: 'free',
institution: {
name: 'University Name',
isUniversity: true,
confirmed: true,
},
last_day_to_reconfirm: undefined,
past_reconfirm_date: false,
portal: undefined,
group: { _id: 'grp1', domainCaptureEnabled: true },
domainCapturedByGroup: true,
},
]
ctx.getUserAffiliations.resolves(affiliationsData)
const fullEmails = await ctx.UserGetter.promises.getUserFullEmails(
ctx.fakeUser._id
)
assert.strictEqual(fullEmails[0].affiliation.domainCapturedByGroup, true)
})
it('should include domainCapturedByGroup=false in merged affiliation when not captured', async function (ctx) {
ctx.UserGetter.promises.getUser = sinon.stub().resolves(ctx.fakeUser)
const affiliationsData = [
{
email: 'email1@foo.bar',
role: null,
cached_confirmed_at: null,
cached_reconfirmed_at: null,
department: null,
entitlement: false,
inferred: false,
licence: 'free',
institution: {
name: 'University Name',
isUniversity: true,
confirmed: true,
},
last_day_to_reconfirm: undefined,
past_reconfirm_date: false,
portal: undefined,
group: { _id: 'grp1', domainCaptureEnabled: true },
domainCapturedByGroup: false,
},
]
ctx.getUserAffiliations.resolves(affiliationsData)
const fullEmails = await ctx.UserGetter.promises.getUserFullEmails(
ctx.fakeUser._id
)
assert.strictEqual(fullEmails[0].affiliation.domainCapturedByGroup, false)
})
it('should merge SAML identifier', async function (ctx) {
const fakeSamlIdentifiers = [
{ providerId: 'saml_id', externalUserId: 'whatever' },

View File

@@ -9,6 +9,7 @@ export type Affiliation = {
cachedPastReconfirmDate: boolean
cachedReconfirmedAt: Nullable<string>
department: Nullable<string>
domainCapturedByGroup?: boolean
inReconfirmNotificationPeriod: boolean
inferred: boolean
institution: Institution