mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 09:09:36 +02:00
Merge pull request #33335 from overleaf/jel-add-email-captured-by-group
[web] Group with domain capture takes priority over Commons when adding new email GitOrigin-RevId: 40eb561018f4be0badf9f3885d24553c5f8bbde7
This commit is contained in:
@@ -264,7 +264,24 @@ function AddEmailViaSSO({
|
||||
domainInfo: DomainInfo
|
||||
userInstitutions: string[]
|
||||
}) {
|
||||
if (domainInfo.university.ssoEnabled) {
|
||||
if (
|
||||
domainInfo.group?.domainCaptureEnabled &&
|
||||
domainInfo.group?.managedUsersEnabled
|
||||
) {
|
||||
return (
|
||||
<Notification
|
||||
type="error"
|
||||
ariaLive="polite"
|
||||
content={
|
||||
<>
|
||||
Your company email address has been registered under a verified
|
||||
domain, and cannot be added as a secondary email. Please create a
|
||||
new <strong>Overleaf</strong> account linked to this email address.
|
||||
</>
|
||||
}
|
||||
/>
|
||||
)
|
||||
} else if (domainInfo.university.ssoEnabled) {
|
||||
// Check if the user has already linked this institution
|
||||
if (userInstitutions.includes(domainInfo.university.id.toString())) {
|
||||
return (
|
||||
@@ -281,23 +298,6 @@ function AddEmailViaSSO({
|
||||
)
|
||||
}
|
||||
return <SsoLinkingInfo email={email} domainInfo={domainInfo} />
|
||||
} else if (
|
||||
domainInfo.group?.domainCaptureEnabled &&
|
||||
domainInfo.group?.managedUsersEnabled
|
||||
) {
|
||||
return (
|
||||
<Notification
|
||||
type="error"
|
||||
ariaLive="polite"
|
||||
content={
|
||||
<>
|
||||
Your company email address has been registered under a verified
|
||||
domain, and cannot be added as a secondary email. Please create a
|
||||
new <strong>Overleaf</strong> account linked to this email address.
|
||||
</>
|
||||
}
|
||||
/>
|
||||
)
|
||||
} else if (
|
||||
domainInfo.group?.domainCaptureEnabled &&
|
||||
domainInfo.group?.ssoConfig?.enabled
|
||||
|
||||
@@ -830,8 +830,7 @@ describe('<EmailsSection />', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describe('if Commons SSO then enabled, that takes priority over group UI', function () {
|
||||
// we shouldn't have SSO config in v1 and in v2 but adding test to ensure Commons takes priority
|
||||
describe('if Commons SSO is enabled and managed users is not enabled, Commons takes priority over group UI', function () {
|
||||
beforeEach(async function () {
|
||||
await fetchMock.callHistory.flush(true)
|
||||
fetchMock.removeRoutes().clearHistory()
|
||||
@@ -874,5 +873,57 @@ describe('<EmailsSection />', function () {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('if Commons SSO is enabled and managed users is enabled, group domain capture takes priority', function () {
|
||||
beforeEach(async function () {
|
||||
await fetchMock.callHistory.flush(true)
|
||||
fetchMock.removeRoutes().clearHistory()
|
||||
const institution = {
|
||||
university: {
|
||||
id: 1234,
|
||||
ssoEnabled: true,
|
||||
name: 'Auto Complete University',
|
||||
},
|
||||
hostname: 'autocomplete.edu',
|
||||
confirmed: true,
|
||||
group: {
|
||||
domainCaptureEnabled: true,
|
||||
managedUsersEnabled: true,
|
||||
ssoConfig: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
fetchMock.get('express:/institutions/domains', [institution])
|
||||
})
|
||||
|
||||
it('renders group domain-capture error instead of Commons UI', async function () {
|
||||
fetchMock.get('/user/emails?ensureAffiliation=true', [])
|
||||
render(<EmailsSection />)
|
||||
|
||||
const button = await screen.findByRole<HTMLButtonElement>('button', {
|
||||
name: 'Add another email',
|
||||
})
|
||||
|
||||
await userEvent.click(button)
|
||||
|
||||
const input = screen.getByRole('textbox', { name: 'Email' })
|
||||
fireEvent.change(input, {
|
||||
target: { value: 'user@autocomplete.edu' },
|
||||
})
|
||||
|
||||
const notification = await screen.findByRole('alert')
|
||||
within(notification).getByText(
|
||||
'Your company email address has been registered under a verified domain, and cannot be added as a secondary email.',
|
||||
{ exact: false }
|
||||
)
|
||||
expect(
|
||||
screen.queryByRole('button', {
|
||||
name: 'Link accounts and add email',
|
||||
})
|
||||
).to.be.null
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user