[PR #835] [MERGED] feat: add email regex validation for user registration #794

Closed
opened 2026-02-26 21:32:58 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/dreamhunter2333/cloudflare_temp_email/pull/835
Author: @dreamhunter2333
Created: 2/15/2026
Status: Merged
Merged: 2/16/2026
Merged by: @dreamhunter2333

Base: mainHead: feature/email


📝 Commits (1)

  • d406ce3 feat: add email regex validation for user registration

📊 Changes

6 files changed (+47 additions, -1 deletions)

View changed files

📝 frontend/src/views/admin/UserSettings.vue (+16 -0)
📝 worker/src/i18n/en.ts (+1 -0)
📝 worker/src/i18n/type.ts (+1 -0)
📝 worker/src/i18n/zh.ts (+1 -0)
📝 worker/src/models/index.ts (+6 -1)
📝 worker/src/user_api/user.ts (+22 -0)

📄 Description

User description

Changes

用户注册增加邮箱正则表达式校验功能,管理员可在后台配置正则规则(如禁止 @ 前面有 .)。

Backend

  • UserSettings model 增加 enableEmailCheckRegexemailCheckRegex 字段
  • registerverifyCode 两个接口都增加正则校验,位于域名白名单检查之后
  • i18n 增加 UserEmailNotMatchRegexMsg 错误消息(中/英)

Frontend

  • 管理员用户设置页面增加「启用邮箱正则校验」开关 + 正则输入框
  • UI 布局与现有域名白名单一致(checkbox + input)

Compatibility

  • 向后兼容:旧数据无新字段时 enableEmailCheckRegexundefined,不进入校验逻辑
  • 正则匹配 = 允许通过,不匹配 = 拒绝,与 ADDRESS_CHECK_REGEX 逻辑一致

PR Type

Enhancement, Tests


Description

  • Added configurable email regex validation for user registration.

  • Updated frontend to include regex input and toggle in user settings.

  • Enhanced backend to validate email format during registration and verification.

  • Added new i18n messages for regex validation errors in multiple languages.


Diagram Walkthrough

flowchart LR
  Frontend["Frontend Updates"] -- "Add regex toggle & input" --> Backend["Backend Updates"]
  Backend -- "Validate email format" --> Registration["Registration Process"]
  Backend -- "Validate email format" --> Verification["Verification Process"]
  Backend -- "Error messages" --> i18n["i18n Updates"]

File Walkthrough

Relevant files
Enhancement
UserSettings.vue
Add UI for email regex validation settings                             

frontend/src/views/admin/UserSettings.vue

  • Added UI elements for email regex validation toggle and input.
  • Updated localization strings for regex-related labels.
  • Integrated regex validation settings into user settings form.
+16/-0   
en.ts
Add English i18n message for regex validation                       

worker/src/i18n/en.ts

  • Added new English message for regex validation error.
+1/-0     
type.ts
Update type definitions for regex validation message         

worker/src/i18n/type.ts

  • Added new type definition for regex validation error message.
+1/-0     
zh.ts
Add Chinese i18n message for regex validation                       

worker/src/i18n/zh.ts

  • Added new Chinese message for regex validation error.
+1/-0     
index.ts
Extend UserSettings model with regex validation fields     

worker/src/models/index.ts

  • Added enableEmailCheckRegex and emailCheckRegex fields to UserSettings
    model.
  • Updated constructor to handle new fields.
+6/-1     
user.ts
Add email regex validation to user API endpoints                 

worker/src/user_api/user.ts

  • Implemented email regex validation in registration and verification
    endpoints.
  • Added error handling for invalid regex patterns.
+22/-0   


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/dreamhunter2333/cloudflare_temp_email/pull/835 **Author:** [@dreamhunter2333](https://github.com/dreamhunter2333) **Created:** 2/15/2026 **Status:** ✅ Merged **Merged:** 2/16/2026 **Merged by:** [@dreamhunter2333](https://github.com/dreamhunter2333) **Base:** `main` ← **Head:** `feature/email` --- ### 📝 Commits (1) - [`d406ce3`](https://github.com/dreamhunter2333/cloudflare_temp_email/commit/d406ce31823baccf5df21283b8167b9b4b149dc3) feat: add email regex validation for user registration ### 📊 Changes **6 files changed** (+47 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `frontend/src/views/admin/UserSettings.vue` (+16 -0) 📝 `worker/src/i18n/en.ts` (+1 -0) 📝 `worker/src/i18n/type.ts` (+1 -0) 📝 `worker/src/i18n/zh.ts` (+1 -0) 📝 `worker/src/models/index.ts` (+6 -1) 📝 `worker/src/user_api/user.ts` (+22 -0) </details> ### 📄 Description ### **User description** ## Changes 用户注册增加邮箱正则表达式校验功能,管理员可在后台配置正则规则(如禁止 `@` 前面有 `.`)。 ### Backend - `UserSettings` model 增加 `enableEmailCheckRegex` 和 `emailCheckRegex` 字段 - `register` 和 `verifyCode` 两个接口都增加正则校验,位于域名白名单检查之后 - i18n 增加 `UserEmailNotMatchRegexMsg` 错误消息(中/英) ### Frontend - 管理员用户设置页面增加「启用邮箱正则校验」开关 + 正则输入框 - UI 布局与现有域名白名单一致(checkbox + input) ### Compatibility - 向后兼容:旧数据无新字段时 `enableEmailCheckRegex` 为 `undefined`,不进入校验逻辑 - 正则匹配 = 允许通过,不匹配 = 拒绝,与 `ADDRESS_CHECK_REGEX` 逻辑一致 ___ ### **PR Type** Enhancement, Tests ___ ### **Description** - Added configurable email regex validation for user registration. - Updated frontend to include regex input and toggle in user settings. - Enhanced backend to validate email format during registration and verification. - Added new i18n messages for regex validation errors in multiple languages. ___ ### Diagram Walkthrough ```mermaid flowchart LR Frontend["Frontend Updates"] -- "Add regex toggle & input" --> Backend["Backend Updates"] Backend -- "Validate email format" --> Registration["Registration Process"] Backend -- "Validate email format" --> Verification["Verification Process"] Backend -- "Error messages" --> i18n["i18n Updates"] ``` <details> <summary><h3> File Walkthrough</h3></summary> <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>UserSettings.vue</strong><dd><code>Add UI for email regex validation settings</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> frontend/src/views/admin/UserSettings.vue <ul><li>Added UI elements for email regex validation toggle and input.<br> <li> Updated localization strings for regex-related labels.<br> <li> Integrated regex validation settings into user settings form.</ul> </details> </td> <td><a href="https://github.com/dreamhunter2333/cloudflare_temp_email/pull/835/files#diff-a98f69fcb5511514645cc9fa9da3b2df48f6f7642526e8bd05e0912414bbded0">+16/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>en.ts</strong><dd><code>Add English i18n message for regex validation</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> worker/src/i18n/en.ts - Added new English message for regex validation error. </details> </td> <td><a href="https://github.com/dreamhunter2333/cloudflare_temp_email/pull/835/files#diff-866bab2459173d441c05aaffe80d1c0d5aaef950056259c00364174c71a5b20c">+1/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>type.ts</strong><dd><code>Update type definitions for regex validation message</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> worker/src/i18n/type.ts - Added new type definition for regex validation error message. </details> </td> <td><a href="https://github.com/dreamhunter2333/cloudflare_temp_email/pull/835/files#diff-93a787364db63c92c7cff26f2a070af388094baa0b813de844843d5978808945">+1/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>zh.ts</strong><dd><code>Add Chinese i18n message for regex validation</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> worker/src/i18n/zh.ts - Added new Chinese message for regex validation error. </details> </td> <td><a href="https://github.com/dreamhunter2333/cloudflare_temp_email/pull/835/files#diff-afab3b78ff6b384c74a17417198e84933a9dfb3cd845fab91db1000084e192e1">+1/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>index.ts</strong><dd><code>Extend UserSettings model with regex validation fields</code>&nbsp; &nbsp; &nbsp; </dd></summary> <hr> worker/src/models/index.ts <ul><li>Added <code>enableEmailCheckRegex</code> and <code>emailCheckRegex</code> fields to <code>UserSettings</code> <br>model.<br> <li> Updated constructor to handle new fields.</ul> </details> </td> <td><a href="https://github.com/dreamhunter2333/cloudflare_temp_email/pull/835/files#diff-430bcc4ffa98738e7419c774a53ba2ce8b5127a36b3741e89bf36b95a56f02bc">+6/-1</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>user.ts</strong><dd><code>Add email regex validation to user API endpoints</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> worker/src/user_api/user.ts <ul><li>Implemented email regex validation in registration and verification <br>endpoints.<br> <li> Added error handling for invalid regex patterns.</ul> </details> </td> <td><a href="https://github.com/dreamhunter2333/cloudflare_temp_email/pull/835/files#diff-aafbb1e6861a3f5ecb2bd9d51e2bf9f11f13aa96302eb755f91c233bae2a296e">+22/-0</a>&nbsp; &nbsp; </td> </tr> </table></td></tr></tr></tbody></table> </details> ___ --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-26 21:32:58 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/cloudflare_temp_email#794
No description provided.