mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 17:19:37 +02:00
Merge pull request #28710 from overleaf/jel-no-sso-notifications-when-domain-capture
[web] Do not show notification to link to Commons SSO when domain is also for group with domain capture GitOrigin-RevId: 6779e2db02d5d9cc4e7a60789a620403a4e4aa11
This commit is contained in:
@@ -53,6 +53,11 @@ const _ssoAvailable = (affiliation, session, linkedInstitutionIds) => {
|
||||
// Do not show SSO UI for unconfirmed domains
|
||||
if (!affiliation.institution.confirmed) return false
|
||||
|
||||
// If ssoEnabled = true and group.domainCaptureEnabled = true
|
||||
// then Commons is migrating to group subscription and we do not want to prompt
|
||||
// linking through Commons SSO
|
||||
if (affiliation?.group?.domainCaptureEnabled) return false
|
||||
|
||||
// Could have multiple emails at the same institution, and if any are
|
||||
// linked to the institution then do not show notification for others
|
||||
if (
|
||||
|
||||
@@ -110,6 +110,15 @@ function SSOAffiliationInfo({ userEmailData }: SSOAffiliationInfoProps) {
|
||||
)
|
||||
}
|
||||
|
||||
const domainAlsoForGroupWithDomainCapture =
|
||||
userEmailData?.affiliation?.group?.domainCaptureEnabled
|
||||
|
||||
if (domainAlsoForGroupWithDomainCapture) {
|
||||
// user is not linked via Commons and should link via groups
|
||||
// do not show UI to link to Commons
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<OLRow>
|
||||
<OLCol lg={{ span: 8, offset: 4 }}>
|
||||
|
||||
@@ -117,5 +117,45 @@ describe('<EmailsRow/>', function () {
|
||||
.null
|
||||
})
|
||||
})
|
||||
|
||||
describe('and domain capture is also on for group and Commons SSO also enabled', function () {
|
||||
// scenario of a Commons account migrating to a group account
|
||||
let affiliatedEmailWithDomainCaptureAndCommons: UserEmailData & {
|
||||
affiliation: Affiliation
|
||||
}
|
||||
beforeEach(async function () {
|
||||
fetchMock.removeRoutes().clearHistory()
|
||||
|
||||
affiliatedEmailWithDomainCaptureAndCommons = cloneDeep(affiliatedEmail)
|
||||
affiliatedEmailWithDomainCaptureAndCommons.affiliation.group = {
|
||||
_id: 'grou123',
|
||||
domainCaptureEnabled: true,
|
||||
managedUsersEnabled: true,
|
||||
}
|
||||
|
||||
await fetchMock.callHistory.flush(true)
|
||||
})
|
||||
|
||||
it('does not prompt the user to link to their institutional account', function () {
|
||||
renderEmailsRow(affiliatedEmailWithDomainCaptureAndCommons)
|
||||
expect(() =>
|
||||
getByTextContent(
|
||||
'You can now link your Overleaf account to your Overleaf institutional account.'
|
||||
)
|
||||
).to.throw('Unable to find an element with the text')
|
||||
expect(screen.queryByRole('button', { name: 'Link accounts' })).to.be
|
||||
.null
|
||||
})
|
||||
|
||||
it('still shows users can log in via Commons SSO if already linked', function () {
|
||||
affiliatedEmailWithDomainCaptureAndCommons.samlProviderId = '1'
|
||||
renderEmailsRow(affiliatedEmailWithDomainCaptureAndCommons)
|
||||
getByTextContent(
|
||||
'You can log in to Overleaf through your Overleaf institutional login.'
|
||||
)
|
||||
expect(screen.queryByRole('button', { name: 'Link accounts' })).to.be
|
||||
.null
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -799,6 +799,29 @@ describe('ProjectListController', function () {
|
||||
ctx.ProjectListController.projectListPage(ctx.req, ctx.res)
|
||||
})
|
||||
})
|
||||
describe('group domain capture enabled for domain', function () {
|
||||
it('does not show institution SSO available notification', function (ctx) {
|
||||
ctx.UserGetter.promises.getUserFullEmails.resolves([
|
||||
{
|
||||
email: 'test@overleaf.com',
|
||||
affiliation: {
|
||||
group: { domainCaptureEnabled: true },
|
||||
institution: {
|
||||
id: 1,
|
||||
confirmed: true,
|
||||
name: 'Overleaf',
|
||||
ssoBeta: false,
|
||||
ssoEnabled: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
])
|
||||
ctx.res.render = (pageName, opts) => {
|
||||
expect(opts.notificationsInstitution).to.deep.equal([])
|
||||
ctx.ProjectListController.projectListPage(ctx.req, ctx.res)
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('Without Institution SSO feature', function () {
|
||||
|
||||
@@ -16,4 +16,9 @@ export type Affiliation = {
|
||||
pastReconfirmDate: boolean
|
||||
portal: Portal
|
||||
role: Nullable<string>
|
||||
group?: {
|
||||
domainCaptureEnabled: boolean
|
||||
managedUsersEnabled: boolean
|
||||
_id: string
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user