mirror of
https://github.com/dreamhunter2333/cloudflare_temp_email.git
synced 2026-04-25 13:55:53 +03:00
[PR #819] [MERGED] fix(user): enforce address count limit when anonymous creation disabled #786
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/cloudflare_temp_email#786
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/dreamhunter2333/cloudflare_temp_email/pull/819
Author: @dreamhunter2333
Created: 1/23/2026
Status: ✅ Merged
Merged: 1/23/2026
Merged by: @dreamhunter2333
Base:
main← Head:feature/email📝 Commits (1)
8ee65ebfix(user): enforce address count limit when anonymous creation disabled📊 Changes
5 files changed (+89 additions, -45 deletions)
View changed files
📝
CHANGELOG.md(+15 -1)📝
CHANGELOG_EN.md(+15 -1)📝
worker/src/mails_api/index.ts(+13 -2)📝
worker/src/user_api/bind_address.ts(+5 -41)📝
worker/src/utils.ts(+41 -0)📄 Description
User description
问题描述
当
DISABLE_ANONYMOUS_USER_CREATE_EMAIL=true时,已登录用户创建地址时没有检查地址数量限制,导致用户可以创建超过限制数量的地址。修复内容
1. 新增地址数量限制检查
/api/new_address接口中,当禁止匿名创建且用户已登录时,创建地址前检查用户的地址数量限制2. 提取公共函数
isAddressCountLimitReached()函数,统一处理地址数量限制检查逻辑getMaxAddressCount()函数,获取用户的最大地址数量(支持角色配置)bind_address.ts中的 3 处重复代码,使用新的公共函数3. 代码改进
isAddressCountLimitReached明确表示"是否已达到限制"修改的文件
worker/src/utils.ts: 新增公共函数worker/src/mails_api/index.ts: 添加地址数量检查worker/src/user_api/bind_address.ts: 重构使用公共函数CHANGELOG.md/CHANGELOG_EN.md: 更新 v1.3.0 变更日志测试
相关 Issue
Fixes #[issue_number]
PR Type
Bug fix, Enhancement
Description
Enforced address count limit for logged-in users when anonymous creation is disabled.
Extracted and centralized address count limit logic into reusable functions.
Refactored code to improve maintainability and reduce duplication.
Updated changelogs to document the changes and improvements.
Diagram Walkthrough
File Walkthrough
index.ts
Enforce address count limit in new address APIworker/src/mails_api/index.ts
/api/new_address.isAddressCountLimitReachedfor logged-in users.bind_address.ts
Refactor address binding to use centralized limit checkworker/src/user_api/bind_address.ts
isAddressCountLimitReachedfor address binding.utils.ts
Add reusable functions for address count limit checksworker/src/utils.ts
isAddressCountLimitReachedto check address limits.getMaxAddressCountto fetch role-based address limits.CHANGELOG.md
Update changelog for v1.3.0 with bug fixes and improvementsCHANGELOG.md
CHANGELOG_EN.md
Update English changelog for v1.3.0 with bug fixes and improvementsCHANGELOG_EN.md
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.