feat(desktop): add email verification prompt and translation support
Part of #3249
After:
https://github.com/user-attachments/assets/589afa8f-a014-4fad-a7ba-664ce4325815
Thank you for your contribution. We will review it promptly.
@kovsu is attempting to deploy a commit to the RSS3 Team on Vercel.
A member of the Team first needs to authorize it.
Suggested PR Title:
feat: add email verification messages and improve UI
Change Summary: Added email verification messages and improved UI for email confirmation in both English and Chinese localizations. Enhanced user experience by integrating translations and managing toast notifications properly.
Code Review:
Code Review
Issues Requiring Change Requests
-
File:
apps/desktop/src/renderer/src/modules/app-layout/feed-column/index.shared.tsx-
Lines: 61-65
-
Issue: The current implementation of the
onClickhandler for the "Send verification email" button does not handle potential errors from thesendVerificationEmailfunction. If the API call to send the email fails for some reason, the user will not be informed, and the button will remain in the "disabled" state (isEmailVerificationSentset totrue). -
Change Request: Add error handling for the
sendVerificationEmailfunction. Ensure that if the API call fails, the user is notified (e.g., viatoast.error) and the button is re-enabled by resettingisEmailVerificationSenttofalse.Example:
onClick={async () => { setIsEmailVerificationSent(true) try { await sendVerificationEmail({ email: user.email, callbackURL: `${WEB_URL}/login`, }) toast.dismiss("email-verification") setTimeout(() => { toast.success(t("profile.email.verification_sent")) }, 800) } catch (error) { setIsEmailVerificationSent(false) toast.error(t("profile.email.verification_failed")) // Add this translation key to the JSON files } }}
-
-
File:
apps/desktop/src/renderer/src/modules/app-layout/feed-column/index.shared.tsx- Lines: 53, 65
-
Issue: The string
profile.email.send_verificationused to localize the "Send verification email" button text is referred to in the JSX code, but it is missing from bothapps/desktop/locales/settings/en.jsonandapps/desktop/locales/settings/zh-CN.json. This will result in missing translations when the application runs. -
Change Request: Add the
profile.email.send_verificationstring to the localization JSON files. Example:- For
en.json:"profile.email.send_verification": "Send verification email" - For
zh-CN.json:"profile.email.send_verification": "发送验证邮件"
- For
-
File:
apps/desktop/locales/settings/en.json- Lines: Existing structure
-
Issue: The placeholder
{{email_address}}used inprofile.email.verify_emailis a dynamic variable. The surrounding translation code inindex.shared.tsxassumes its safe usage, but there is no explicit sanitization or escaping of the dynamic values used in translations. Although this may typically be handled upstream byreact-i18next, it’s still worth verifying or documenting. -
Change Request: Ensure dynamic values such as
email_addressare properly sanitized or escaped to prevent possible script injection attacks. This may involve validating input in the backend or modifying usage in the frontend with an escaping function.
Summary of Required Changes
- Add error handling for
sendVerificationEmailinindex.shared.tsxto manage API call failures gracefully. - Add the missing
profile.email.send_verificationlocalization key in bothen.jsonandzh-CN.jsonfiles. - Ensure dynamic placeholders in translations are sanitized to prevent misuse or injection.
These changes are critical to enhance error handling, complete localization, and ensure the application’s security.
Thank you @kovsu for your contribution! 🎉
Your pull request has been merged and we really appreciate your help in making this project better. We hope to see more contributions from you in the future! 💪