* Rename `checkSecondaryEmailConfirmationCode` to `checkAddSecondaryEmailConfirmationCode` * Create function `sendCodeAndStoreInSession` * Create function `sendExistingSecondaryEmailConfirmationCode` * Create function `_checkConfirmationCode` * Create function `checkExistingEmailConfirmationCode` * Rename `resendSecondaryEmailConfirmationCode` to `resendAddSecondaryEmailConfirmationCode` * Create function `_resendConfirmationCode` * Create function `resendExistingSecondaryEmailConfirmationCode` * Add `ResendConfirmationCodeModal` * Remove `ResendConfirmationEmailButton` * `bin/run web npm run extract-translations` * Update frontend test * Fix: don't throw on render when send-confirmation-code fails! * Update phrasing in the UI Per https://docs.google.com/document/d/1PE1vlZWQN--PjmXpyHR9rV2YPd7OIPIsUbnZaHj0cDI/edit?usp=sharing * Add unit test * Don't share the "send-confirmation" and "resend-confirmation" rate-limits * Update frontend test after copy change * Rename `checkAddSecondaryEmailConfirmationCode` to `checkNewSecondaryEmailConfirmationCode` and `resendAddSecondaryEmailConfirmationCode` to `resendNewSecondaryEmailConfirmationCode` * Rename `cb` to `beforeConfirmEmail` Co-authored-by: Jakob Ackermann <jakob.ackermann@overleaf.com> * Return `422` on missing session data Co-authored-by: Jakob Ackermann <jakob.ackermann@overleaf.com> * Add `userId` to log * Replace `isSecondary` param by `welcomeUser` Co-authored-by: Jakob Ackermann <jakob.ackermann@overleaf.com> * Rename `resend-confirm-email-code`'s `existingEmail` to `email` * Remove "secondary" from rate-limiters Co-authored-by: Jakob Ackermann <jakob.ackermann@overleaf.com> * Remove unnecessary `userId` check behind `AuthenticationController.requireLogin()` * Only open the modal if the code was sent successfully --------- Co-authored-by: Jakob Ackermann <jakob.ackermann@overleaf.com> GitOrigin-RevId: df892064641d9f722785699777383b2d863124e1
56 lines
1.6 KiB
TypeScript
56 lines
1.6 KiB
TypeScript
import { useTranslation } from 'react-i18next'
|
|
import { UserEmailData } from '../../../../../../types/user-email'
|
|
import { ssoAvailableForInstitution } from '../../utils/sso'
|
|
import OLBadge from '@/features/ui/components/ol/ol-badge'
|
|
import { isBootstrap5 } from '@/features/utils/bootstrap-5'
|
|
import classnames from 'classnames'
|
|
import ResendConfirmationCodeModal from '@/features/settings/components/emails/resend-confirmation-code-modal'
|
|
|
|
type EmailProps = {
|
|
userEmailData: UserEmailData
|
|
}
|
|
|
|
function Email({ userEmailData }: EmailProps) {
|
|
const { t } = useTranslation()
|
|
|
|
const ssoAvailable = ssoAvailableForInstitution(
|
|
userEmailData.affiliation?.institution || null
|
|
)
|
|
|
|
const isPrimary = userEmailData.default
|
|
const isProfessional =
|
|
userEmailData.confirmedAt &&
|
|
userEmailData.affiliation?.institution.confirmed &&
|
|
userEmailData.affiliation.licence !== 'free'
|
|
const hasBadges = isPrimary || isProfessional
|
|
|
|
return (
|
|
<>
|
|
{userEmailData.email}
|
|
{!userEmailData.confirmedAt && (
|
|
<div className="small">
|
|
<strong>{t('unconfirmed')}.</strong>
|
|
<br />
|
|
{!ssoAvailable && (
|
|
<ResendConfirmationCodeModal email={userEmailData.email} />
|
|
)}
|
|
</div>
|
|
)}
|
|
{hasBadges && (
|
|
<div className={classnames({ small: !isBootstrap5() })}>
|
|
{isPrimary && (
|
|
<>
|
|
<OLBadge bg="info">Primary</OLBadge>{' '}
|
|
</>
|
|
)}
|
|
{isProfessional && (
|
|
<OLBadge bg="primary">{t('professional')}</OLBadge>
|
|
)}
|
|
</div>
|
|
)}
|
|
</>
|
|
)
|
|
}
|
|
|
|
export default Email
|