Skip to content

Commit

Permalink
Merge pull request #4872 from Giveth/fix/email_verification
Browse files Browse the repository at this point in the history
Fix/Email verification bugs
  • Loading branch information
kkatusic authored Nov 25, 2024
2 parents 606ca16 + e8eaac8 commit 3163ba5
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lang/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@
"label.email_used_another": "Aquest correu electrònic ja ha estat verificat en un altre perfil!",
"label.email_sent_to": "Codi de verificació enviat a {email}",
"label.email_please_verify": "Si us plau, verifica el teu correu electrònic. Introdueix el codi de confirmació enviat al teu correu.",
"label.email_get_resend": "No has rebut el correu? Revisa la teva carpeta de correu brossa o <button>Reenvia l'enllaç de verificació!</button>",
"label.email_get_resend": "No has rebut el correu electrònic? Revisa la teva carpeta de correu brossa o <button>Torna a enviar el codi de verificació!</button>",
"label.email_confirm_code": "Confirma el codi",
"label.email_verify_banner": "Obté l'accés complet als teus comptes i projectes. Verifica la teva adreça de correu electrònic! <button>Verifica el correu</button>",
"label.email_actions_text": "Verifica el teu correu electrònic per gestionar els teus projectes!",
Expand Down
2 changes: 1 addition & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@
"label.email_used_another": "This email that has already been verified on another profile!",
"label.email_sent_to": "Verification code sent to {email}",
"label.email_please_verify": "Please Verify your email. Enter the confirmation code sent to your email.",
"label.email_get_resend": "Didn't get the email? Check your spam folder or <button>Resend Verification Link!</button>",
"label.email_get_resend": "Didn't get the email? Check your spam folder or <button>Resend Verification Code!</button>",
"label.email_confirm_code": "Confirm Code",
"label.email_verify_banner": "Get the full access to your accounts and projects. Verify your email address! <button>Verify email</button>",
"label.email_actions_text": "Verify your email to manage your projects!",
Expand Down
2 changes: 1 addition & 1 deletion lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@
"label.email_used_another": "¡Este correo electrónico ya ha sido verificado en otro perfil!",
"label.email_sent_to": "Código de verificación enviado a {email}",
"label.email_please_verify": "Por favor, verifica tu correo electrónico. Ingresa el código de confirmación enviado a tu correo.",
"label.email_get_resend": "¿No recibiste el correo? Revisa tu carpeta de spam o <button>¡Reenviar enlace de verificación!</button>",
"label.email_get_resend": "¿No recibiste el correo electrónico? Revisa tu carpeta de spam o <button>¡Reenviar código de verificación!</button>",
"label.email_confirm_code": "Confirmar código",
"label.email_verify_banner": "Obtén acceso completo a tus cuentas y proyectos. ¡Verifica tu dirección de correo electrónico! <button>Verificar correo</button>",
"label.email_actions_text": "¡Verifica tu correo electrónico para gestionar tus proyectos!",
Expand Down
11 changes: 10 additions & 1 deletion src/components/InputUserEmailVerify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,14 @@ const InputSizeToLinkSize = (size: InputSize) => {
};

type InputType =
| IInputWithRegister
| (IInputWithRegister & {
verifiedSaveButton?: (verified: boolean) => void;
})
| ({
registerName?: never;
register?: never;
registerOptions?: never;
verifiedSaveButton?: (verified: boolean) => void;
} & IInput);

interface IExtendedInputLabelProps extends IInputLabelProps {
Expand Down Expand Up @@ -209,8 +212,13 @@ const InputUserEmailVerify = forwardRef<HTMLInputElement, InputType>(
// Check if user is changing email address
if (e.target.value !== user.email) {
setVerified(false);
props.verifiedSaveButton && props.verifiedSaveButton(false);
} else if (e.target.value !== user.email && user.isEmailVerified) {
setVerified(true);
props.verifiedSaveButton && props.verifiedSaveButton(true);
} else if (e.target.value === user.email && user.isEmailVerified) {
setVerified(true);
props.verifiedSaveButton && props.verifiedSaveButton(true);
}
};

Expand Down Expand Up @@ -285,6 +293,7 @@ const InputUserEmailVerify = forwardRef<HTMLInputElement, InputType>(
setIsVerificationProcess(false);
setDisableCodeVerifyButton(true);
setVerified(true);
props.verifiedSaveButton && props.verifiedSaveButton(true);
setValidationCodeStatus(EInputValidation.SUCCESS);

// Update user data
Expand Down
6 changes: 5 additions & 1 deletion src/components/modals/EditUserModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const EditUserModal = ({
const { walletAddress: address } = useGeneralWallet();

const [updateUser] = useMutation(UPDATE_USER);
const [verified, setVerified] = useState(user.isEmailVerified);
const { isAnimating, closeModal } = useModalAnimation(setShowModal);

const onSaveAvatar = async () => {
Expand Down Expand Up @@ -191,6 +192,9 @@ const EditUserModal = ({
register={register}
error={(errors as any)[field.name]}
registerOptions={field.registerOptions}
{...(field.type === 'email' && {
verifiedSaveButton: setVerified,
})}
/>
);
})}
Expand All @@ -199,7 +203,7 @@ const EditUserModal = ({
label={formatMessage({
id: 'label.save',
})}
disabled={isLoading}
disabled={isLoading || !verified}
type='submit'
/>
<TextButton
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/project/ProjectIndex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const ProjectIndex: FC<IProjectBySlug> = () => {

return (
<Wrapper>
{!isAdminEmailVerified && <VerifyEmailBanner />}
{!isAdminEmailVerified && isAdmin && <VerifyEmailBanner />}
{hasActiveQFRound && !isOnSolana && <PassportBanner />}
<Head>
<title>{title && `${title} |`} Giveth</title>
Expand Down

0 comments on commit 3163ba5

Please sign in to comment.