diff --git a/services/web/app/src/Features/User/UserGetter.mjs b/services/web/app/src/Features/User/UserGetter.mjs index 4032f4f057..7b1ec0d026 100644 --- a/services/web/app/src/Features/User/UserGetter.mjs +++ b/services/web/app/src/Features/User/UserGetter.mjs @@ -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 diff --git a/services/web/test/unit/src/Project/ProjectListController.test.mjs b/services/web/test/unit/src/Project/ProjectListController.test.mjs index 989f1afd53..a975c18760 100644 --- a/services/web/test/unit/src/Project/ProjectListController.test.mjs +++ b/services/web/test/unit/src/Project/ProjectListController.test.mjs @@ -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' diff --git a/services/web/test/unit/src/User/UserGetter.test.mjs b/services/web/test/unit/src/User/UserGetter.test.mjs index 8943d90deb..7ca9b0f304 100644 --- a/services/web/test/unit/src/User/UserGetter.test.mjs +++ b/services/web/test/unit/src/User/UserGetter.test.mjs @@ -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' }, diff --git a/services/web/types/affiliation.ts b/services/web/types/affiliation.ts index c2e51fe6a2..3e4a2dbace 100644 --- a/services/web/types/affiliation.ts +++ b/services/web/types/affiliation.ts @@ -9,6 +9,7 @@ export type Affiliation = { cachedPastReconfirmDate: boolean cachedReconfirmedAt: Nullable department: Nullable + domainCapturedByGroup?: boolean inReconfirmNotificationPeriod: boolean inferred: boolean institution: Institution