The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/client/providers/UserProvider/hooks/useEmailVerificationWarning...

24 lines
910 B

import type { IUser } from '@rocket.chat/core-typings';
import { useSetting, useToastMessageDispatch } from '@rocket.chat/ui-contexts';
import { useRef, useEffect } from 'react';
import { useTranslation } from 'react-i18next';
export function useEmailVerificationWarning(user: IUser | undefined) {
const emailVerificationEnabled = useSetting('Accounts_EmailVerification', false);
const dispatchToastMessage = useToastMessageDispatch();
const { t } = useTranslation();
const mainEmail = user?.emails?.[0];
const warnedRef = useRef(false);
useEffect(() => {
const { current: warned } = warnedRef;
if (mainEmail && mainEmail.verified !== true && emailVerificationEnabled && !warned) {
dispatchToastMessage({
type: 'warning',
message: t('core.You_have_not_verified_your_email'),
});
warnedRef.current = true;
}
}, [mainEmail, emailVerificationEnabled, dispatchToastMessage, t]);
}