mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 13:13:45 +01:00
[web] Check if domain captured by group when showing confirm email UI GitOrigin-RevId: bb6add82e083497c8036739d877610a47e35ecfd
32 lines
1.0 KiB
TypeScript
32 lines
1.0 KiB
TypeScript
import getMeta from '@/utils/meta'
|
|
import { Affiliation } from '../../../../../types/affiliation'
|
|
import { ssoAvailableForInstitution } from './sso'
|
|
|
|
export const emailMustBeConfirmedViaSAML = (
|
|
affiliation: Affiliation | null
|
|
): boolean => {
|
|
const { hasSamlFeature } = getMeta('ol-ExposedSettings')
|
|
if (
|
|
!hasSamlFeature ||
|
|
!affiliation ||
|
|
!affiliation.institution ||
|
|
!affiliation.institution.confirmed
|
|
) {
|
|
return false
|
|
}
|
|
// both groups and Commons have affiliation.institution, but only Commons has SAML
|
|
// information in affiliation.institution
|
|
// ssoAvailableForInstitution will only check affiliation.institution for Commons
|
|
// and there are different rules for whether SAML is enabled or not for groups with
|
|
// domain capture or Commons
|
|
|
|
const samlViaCommons = ssoAvailableForInstitution(affiliation.institution)
|
|
|
|
const samlViaGroup =
|
|
affiliation.domainCapturedByGroup &&
|
|
affiliation.group?.domainCaptureEnabled &&
|
|
affiliation.group?.managedUsersEnabled
|
|
|
|
return samlViaCommons || samlViaGroup || false
|
|
}
|