diff --git a/services/web/app/src/Features/Project/ProjectController.js b/services/web/app/src/Features/Project/ProjectController.js index 9b5c9ad2ed..ea61c76fdf 100644 --- a/services/web/app/src/Features/Project/ProjectController.js +++ b/services/web/app/src/Features/Project/ProjectController.js @@ -333,13 +333,17 @@ const _ProjectController = { if (domainCaptureRedirect === 'enabled') { const subscription = ( await Modules.promises.hooks.fire( - 'findDomainCaptureAndManagedUsersGroupUserShouldBePartOf', + 'findDomainCaptureGroupUserCouldBePartOf', userId ) )?.[0] if (subscription) { - return res.redirect('/domain-capture') + if (subscription.managedUsersEnabled) { + return res.redirect('/domain-capture') + } else { + // TODO show notification or anything else + } } } } diff --git a/services/web/app/src/Features/Project/ProjectListController.mjs b/services/web/app/src/Features/Project/ProjectListController.mjs index 712168f912..b758bba050 100644 --- a/services/web/app/src/Features/Project/ProjectListController.mjs +++ b/services/web/app/src/Features/Project/ProjectListController.mjs @@ -124,13 +124,17 @@ async function projectListPage(req, res, next) { if (domainCaptureRedirect === 'enabled') { const subscription = ( await Modules.promises.hooks.fire( - 'findDomainCaptureAndManagedUsersGroupUserShouldBePartOf', + 'findDomainCaptureGroupUserCouldBePartOf', userId ) )?.[0] if (subscription) { - return res.redirect('/domain-capture') + if (subscription.managedUsersEnabled) { + return res.redirect('/domain-capture') + } else { + // TODO show notification or anything else + } } } } diff --git a/services/web/frontend/js/utils/meta.ts b/services/web/frontend/js/utils/meta.ts index 46299a5dc1..162ed749f1 100644 --- a/services/web/frontend/js/utils/meta.ts +++ b/services/web/frontend/js/utils/meta.ts @@ -255,6 +255,7 @@ export interface Meta { 'ol-splitTestVariants': { [name: string]: string } 'ol-ssoDisabled': boolean 'ol-ssoErrorMessage': string + 'ol-ssoInitPath': string 'ol-stripeAccountId': string 'ol-stripeSubscriptionData': { customerId: string diff --git a/services/web/test/frontend/features/group-management/components/domain-capture.spec.tsx b/services/web/test/frontend/features/group-management/components/domain-capture.spec.tsx index db89129106..e38134c712 100644 --- a/services/web/test/frontend/features/group-management/components/domain-capture.spec.tsx +++ b/services/web/test/frontend/features/group-management/components/domain-capture.spec.tsx @@ -4,6 +4,7 @@ describe('', function () { beforeEach(function () { this.email = 'user@example.com' this.groupName = 'test-group' + this.ssoInitPath = '/sso/init/path' cy.window().then(win => { win.metaAttributesCache.set('ol-user', { @@ -13,6 +14,7 @@ describe('', function () { }) win.metaAttributesCache.set('ol-email', this.email) win.metaAttributesCache.set('ol-groupName', this.groupName) + win.metaAttributesCache.set('ol-ssoInitPath', this.ssoInitPath) }) cy.mount() @@ -51,7 +53,11 @@ describe('', function () { /get access to enterprise features and benefits provided by your organization/i ) cy.findByText(/you’ll continue to have access to all of your projects/i) - cy.findByRole('button', { name: /join/i }) + cy.findByRole('link', { name: /join/i }).should( + 'have.attr', + 'href', + this.ssoInitPath + ) }) }) diff --git a/services/web/test/unit/src/Project/ProjectControllerTests.js b/services/web/test/unit/src/Project/ProjectControllerTests.js index 2c2f95bfd3..02a75b213a 100644 --- a/services/web/test/unit/src/Project/ProjectControllerTests.js +++ b/services/web/test/unit/src/Project/ProjectControllerTests.js @@ -600,11 +600,8 @@ describe('ProjectController', function () { .withArgs(this.req, this.res, 'domain-capture-redirect') .resolves({ variant: 'enabled' }) this.Modules.promises.hooks.fire - .withArgs( - 'findDomainCaptureAndManagedUsersGroupUserShouldBePartOf', - this.user._id - ) - .resolves([{ _id: new ObjectId() }]) + .withArgs('findDomainCaptureGroupUserCouldBePartOf', this.user._id) + .resolves([{ _id: new ObjectId(), managedUsersEnabled: true }]) this.res.redirect = url => { url.should.equal('/domain-capture') done() diff --git a/services/web/test/unit/src/Project/ProjectListController.test.mjs b/services/web/test/unit/src/Project/ProjectListController.test.mjs index 57ccb5887a..70dd4a6658 100644 --- a/services/web/test/unit/src/Project/ProjectListController.test.mjs +++ b/services/web/test/unit/src/Project/ProjectListController.test.mjs @@ -500,11 +500,8 @@ describe('ProjectListController', function () { .withArgs(ctx.req, ctx.res, 'domain-capture-redirect') .resolves({ variant: 'enabled' }) ctx.Modules.promises.hooks.fire - .withArgs( - 'findDomainCaptureAndManagedUsersGroupUserShouldBePartOf', - ctx.user._id - ) - .resolves([{ _id: new ObjectId() }]) + .withArgs('findDomainCaptureGroupUserCouldBePartOf', ctx.user._id) + .resolves([{ _id: new ObjectId(), managedUsersEnabled: true }]) ctx.res.redirect = url => { url.should.equal('/domain-capture') resolve()