Merge pull request #8102 from overleaf/msm-fix-sso-available

[Settings] Fix `ssoAvailable` not set

GitOrigin-RevId: c3264682bcf3c1beb2050378875c164d960e15c1
This commit is contained in:
Miguel Serrano 2022-05-24 13:12:55 +02:00 committed by Copybot
parent f81c52e6c7
commit 5676ec2eed
3 changed files with 13 additions and 6 deletions

View file

@ -12,6 +12,7 @@ import {
} from '../../../context/user-email-context' } from '../../../context/user-email-context'
import { UserEmailData } from '../../../../../../../types/user-email' import { UserEmailData } from '../../../../../../../types/user-email'
import { UseAsyncReturnType } from '../../../../../shared/hooks/use-async' import { UseAsyncReturnType } from '../../../../../shared/hooks/use-async'
import { ssoAvailableForInstitution } from '../../../utils/sso'
const getDescription = ( const getDescription = (
t: (s: string) => string, t: (s: string) => string,
@ -26,8 +27,12 @@ const getDescription = (
return t('make_email_primary_description') return t('make_email_primary_description')
} }
const ssoAvailable = ssoAvailableForInstitution(
userEmailData.affiliation?.institution
)
if (!institutionAlreadyLinked(state, userEmailData)) { if (!institutionAlreadyLinked(state, userEmailData)) {
return userEmailData.ssoAvailable return ssoAvailable
? t('please_link_before_making_primary') ? t('please_link_before_making_primary')
: t('please_confirm_your_email_before_making_it_default') : t('please_confirm_your_email_before_making_it_default')
} }

View file

@ -1,6 +1,7 @@
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { UserEmailData } from '../../../../../../types/user-email' import { UserEmailData } from '../../../../../../types/user-email'
import ResendConfirmationEmailButton from './resend-confirmation-email-button' import ResendConfirmationEmailButton from './resend-confirmation-email-button'
import { ssoAvailableForInstitution } from '../../utils/sso'
type EmailProps = { type EmailProps = {
userEmailData: UserEmailData userEmailData: UserEmailData
@ -9,6 +10,10 @@ type EmailProps = {
function Email({ userEmailData }: EmailProps) { function Email({ userEmailData }: EmailProps) {
const { t } = useTranslation() const { t } = useTranslation()
const ssoAvailable = ssoAvailableForInstitution(
userEmailData.affiliation?.institution
)
return ( return (
<> <>
{userEmailData.email} {userEmailData.email}
@ -17,12 +22,10 @@ function Email({ userEmailData }: EmailProps) {
<div className="small"> <div className="small">
<strong> <strong>
{t('unconfirmed')}. {t('unconfirmed')}.
{!userEmailData.ssoAvailable && ( {!ssoAvailable && <span> {t('please_check_your_inbox')}.</span>}
<span> {t('please_check_your_inbox')}.</span>
)}
</strong> </strong>
<br /> <br />
{!userEmailData.ssoAvailable && ( {!ssoAvailable && (
<ResendConfirmationEmailButton email={userEmailData.email} /> <ResendConfirmationEmailButton email={userEmailData.email} />
)} )}
</div> </div>

View file

@ -6,6 +6,5 @@ export type UserEmailData = {
email: string email: string
default: boolean default: boolean
samlProviderId?: string samlProviderId?: string
ssoAvailable?: boolean
emailHasInstitutionLicence?: boolean emailHasInstitutionLicence?: boolean
} }