mirror of
https://github.com/dreamhunter2333/cloudflare_temp_email.git
synced 2026-09-04 23:17:34 +08:00
feat: add DISABLE_ANONYMOUS_USER_CREATE_EMAIL which only allow logi… (#545)
feat: add `DISABLE_ANONYMOUS_USER_CREATE_EMAIL` which only allow login user create email address
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
- fix: |UI| 修复 admin portal 无收件人邮箱删除调用api 错误
|
- fix: |UI| 修复 admin portal 无收件人邮箱删除调用api 错误
|
||||||
- feat: |Telegram Bot| 增加 telegram bot 清理无效地址凭证命令
|
- feat: |Telegram Bot| 增加 telegram bot 清理无效地址凭证命令
|
||||||
|
- feat: 增加 worker 配置 `DISABLE_ANONYMOUS_USER_CREATE_EMAIL` 禁用匿名用户创建邮箱地址,只允许登录用户创建邮箱地址
|
||||||
|
|
||||||
## v0.8.3
|
## v0.8.3
|
||||||
|
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ const getOpenSettings = async (message) => {
|
|||||||
}),
|
}),
|
||||||
adminContact: res["adminContact"] || "",
|
adminContact: res["adminContact"] || "",
|
||||||
enableUserCreateEmail: res["enableUserCreateEmail"] || false,
|
enableUserCreateEmail: res["enableUserCreateEmail"] || false,
|
||||||
|
disableAnonymousUserCreateEmail: res["disableAnonymousUserCreateEmail"] || false,
|
||||||
enableUserDeleteEmail: res["enableUserDeleteEmail"] || false,
|
enableUserDeleteEmail: res["enableUserDeleteEmail"] || false,
|
||||||
enableAutoReply: res["enableAutoReply"] || false,
|
enableAutoReply: res["enableAutoReply"] || false,
|
||||||
enableIndexAbout: res["enableIndexAbout"] || false,
|
enableIndexAbout: res["enableIndexAbout"] || false,
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ export const useGlobalState = createGlobalState(
|
|||||||
needAuth: false,
|
needAuth: false,
|
||||||
adminContact: '',
|
adminContact: '',
|
||||||
enableUserCreateEmail: false,
|
enableUserCreateEmail: false,
|
||||||
|
disableAnonymousUserCreateEmail: false,
|
||||||
enableUserDeleteEmail: false,
|
enableUserDeleteEmail: false,
|
||||||
enableAutoReply: false,
|
enableAutoReply: false,
|
||||||
enableIndexAbout: false,
|
enableIndexAbout: false,
|
||||||
|
|||||||
@@ -184,6 +184,15 @@ const domainsOptions = computed(() => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const showNewAddressTab = computed(() => {
|
||||||
|
if (openSettings.value.disableAnonymousUserCreateEmail
|
||||||
|
&& !userSettings.value.user_email
|
||||||
|
) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return openSettings.value.enableUserCreateEmail;
|
||||||
|
});
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
if (!openSettings.value.domains || openSettings.value.domains.length === 0) {
|
if (!openSettings.value.domains || openSettings.value.domains.length === 0) {
|
||||||
await api.getOpenSettings();
|
await api.getOpenSettings();
|
||||||
@@ -209,8 +218,7 @@ onMounted(async () => {
|
|||||||
</template>
|
</template>
|
||||||
{{ t('login') }}
|
{{ t('login') }}
|
||||||
</n-button>
|
</n-button>
|
||||||
<n-button v-if="openSettings.enableUserCreateEmail" @click="tabValue = 'register'" block secondary
|
<n-button v-if="showNewAddressTab" @click="tabValue = 'register'" block secondary strong>
|
||||||
strong>
|
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<n-icon :component="NewLabelOutlined" />
|
<n-icon :component="NewLabelOutlined" />
|
||||||
</template>
|
</template>
|
||||||
@@ -218,7 +226,7 @@ onMounted(async () => {
|
|||||||
</n-button>
|
</n-button>
|
||||||
</n-form>
|
</n-form>
|
||||||
</n-tab-pane>
|
</n-tab-pane>
|
||||||
<n-tab-pane v-if="openSettings.enableUserCreateEmail" name="register" :tab="t('getNewEmail')">
|
<n-tab-pane v-if="showNewAddressTab" name="register" :tab="t('getNewEmail')">
|
||||||
<n-spin :show="generateNameLoading">
|
<n-spin :show="generateNameLoading">
|
||||||
<n-form>
|
<n-form>
|
||||||
<span>
|
<span>
|
||||||
|
|||||||
@@ -107,6 +107,8 @@ JWT_SECRET = "xxx" # Key used to generate jwt
|
|||||||
BLACK_LIST = "" # Blacklist, used to filter senders, comma separated
|
BLACK_LIST = "" # Blacklist, used to filter senders, comma separated
|
||||||
# Allow users to create email addresses
|
# Allow users to create email addresses
|
||||||
ENABLE_USER_CREATE_EMAIL = true
|
ENABLE_USER_CREATE_EMAIL = true
|
||||||
|
# Disable anonymous user create email, if set true, users can only create email addresses after logging in
|
||||||
|
# DISABLE_ANONYMOUS_USER_CREATE_EMAIL = true
|
||||||
# Allow users to delete messages
|
# Allow users to delete messages
|
||||||
ENABLE_USER_DELETE_EMAIL = true
|
ENABLE_USER_DELETE_EMAIL = true
|
||||||
# Allow automatic replies to emails
|
# Allow automatic replies to emails
|
||||||
|
|||||||
@@ -79,6 +79,8 @@ JWT_SECRET = "xxx" # 用于生成 jwt 的密钥, jwt 用于给用户登录以及
|
|||||||
BLACK_LIST = "" # 黑名单,用于过滤发件人,逗号分隔
|
BLACK_LIST = "" # 黑名单,用于过滤发件人,逗号分隔
|
||||||
# 是否允许用户创建邮件, 不配置则不允许
|
# 是否允许用户创建邮件, 不配置则不允许
|
||||||
ENABLE_USER_CREATE_EMAIL = true
|
ENABLE_USER_CREATE_EMAIL = true
|
||||||
|
# 禁用匿名用户创建邮箱,如果设置为 true,则用户只能在登录后创建邮箱地址
|
||||||
|
# DISABLE_ANONYMOUS_USER_CREATE_EMAIL = true
|
||||||
# 允许用户删除邮件, 不配置则不允许
|
# 允许用户删除邮件, 不配置则不允许
|
||||||
ENABLE_USER_DELETE_EMAIL = true
|
ENABLE_USER_DELETE_EMAIL = true
|
||||||
# 允许自动回复邮件
|
# 允许自动回复邮件
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ export default {
|
|||||||
|
|
||||||
"ADMIN_CONTACT": c.env.ADMIN_CONTACT,
|
"ADMIN_CONTACT": c.env.ADMIN_CONTACT,
|
||||||
"ENABLE_USER_CREATE_EMAIL": getBooleanValue(c.env.ENABLE_USER_CREATE_EMAIL),
|
"ENABLE_USER_CREATE_EMAIL": getBooleanValue(c.env.ENABLE_USER_CREATE_EMAIL),
|
||||||
|
"DISABLE_ANONYMOUS_USER_CREATE_EMAIL": getBooleanValue(c.env.DISABLE_ANONYMOUS_USER_CREATE_EMAIL),
|
||||||
"ENABLE_USER_DELETE_EMAIL": getBooleanValue(c.env.ENABLE_USER_DELETE_EMAIL),
|
"ENABLE_USER_DELETE_EMAIL": getBooleanValue(c.env.ENABLE_USER_DELETE_EMAIL),
|
||||||
"ENABLE_AUTO_REPLY": getBooleanValue(c.env.ENABLE_AUTO_REPLY),
|
"ENABLE_AUTO_REPLY": getBooleanValue(c.env.ENABLE_AUTO_REPLY),
|
||||||
"COPYRIGHT": c.env.COPYRIGHT,
|
"COPYRIGHT": c.env.COPYRIGHT,
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ api.get('/open_api/settings', async (c) => {
|
|||||||
"needAuth": needAuth,
|
"needAuth": needAuth,
|
||||||
"adminContact": c.env.ADMIN_CONTACT,
|
"adminContact": c.env.ADMIN_CONTACT,
|
||||||
"enableUserCreateEmail": getBooleanValue(c.env.ENABLE_USER_CREATE_EMAIL),
|
"enableUserCreateEmail": getBooleanValue(c.env.ENABLE_USER_CREATE_EMAIL),
|
||||||
|
"disableAnonymousUserCreateEmail": getBooleanValue(c.env.DISABLE_ANONYMOUS_USER_CREATE_EMAIL),
|
||||||
"enableUserDeleteEmail": getBooleanValue(c.env.ENABLE_USER_DELETE_EMAIL),
|
"enableUserDeleteEmail": getBooleanValue(c.env.ENABLE_USER_DELETE_EMAIL),
|
||||||
"enableAutoReply": getBooleanValue(c.env.ENABLE_AUTO_REPLY),
|
"enableAutoReply": getBooleanValue(c.env.ENABLE_AUTO_REPLY),
|
||||||
"enableIndexAbout": getBooleanValue(c.env.ENABLE_INDEX_ABOUT),
|
"enableIndexAbout": getBooleanValue(c.env.ENABLE_INDEX_ABOUT),
|
||||||
|
|||||||
@@ -103,6 +103,11 @@ api.get('/api/settings', async (c) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
api.post('/api/new_address', async (c) => {
|
api.post('/api/new_address', async (c) => {
|
||||||
|
if (getBooleanValue(c.env.DISABLE_ANONYMOUS_USER_CREATE_EMAIL)
|
||||||
|
&& !c.get("userPayload")
|
||||||
|
) {
|
||||||
|
return c.text("New address for anonymous user is disabled", 403)
|
||||||
|
}
|
||||||
if (!getBooleanValue(c.env.ENABLE_USER_CREATE_EMAIL)) {
|
if (!getBooleanValue(c.env.ENABLE_USER_CREATE_EMAIL)) {
|
||||||
return c.text("New address is disabled", 403)
|
return c.text("New address is disabled", 403)
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+1
@@ -33,6 +33,7 @@ export type Bindings = {
|
|||||||
ENABLE_AUTO_REPLY: string | boolean | undefined
|
ENABLE_AUTO_REPLY: string | boolean | undefined
|
||||||
ENABLE_WEBHOOK: string | boolean | undefined
|
ENABLE_WEBHOOK: string | boolean | undefined
|
||||||
ENABLE_USER_CREATE_EMAIL: string | boolean | undefined
|
ENABLE_USER_CREATE_EMAIL: string | boolean | undefined
|
||||||
|
DISABLE_ANONYMOUS_USER_CREATE_EMAIL: string | boolean | undefined
|
||||||
ENABLE_USER_DELETE_EMAIL: string | boolean | undefined
|
ENABLE_USER_DELETE_EMAIL: string | boolean | undefined
|
||||||
ENABLE_INDEX_ABOUT: string | boolean | undefined
|
ENABLE_INDEX_ABOUT: string | boolean | undefined
|
||||||
DEFAULT_SEND_BALANCE: number | string | undefined
|
DEFAULT_SEND_BALANCE: number | string | undefined
|
||||||
|
|||||||
@@ -49,6 +49,8 @@ JWT_SECRET = "xxx"
|
|||||||
BLACK_LIST = ""
|
BLACK_LIST = ""
|
||||||
# Allow users to create email addresses
|
# Allow users to create email addresses
|
||||||
ENABLE_USER_CREATE_EMAIL = true
|
ENABLE_USER_CREATE_EMAIL = true
|
||||||
|
# Disable anonymous user create email, if set true, users can only create email addresses after logging in
|
||||||
|
# DISABLE_ANONYMOUS_USER_CREATE_EMAIL = true
|
||||||
# Allow users to delete messages
|
# Allow users to delete messages
|
||||||
ENABLE_USER_DELETE_EMAIL = true
|
ENABLE_USER_DELETE_EMAIL = true
|
||||||
# Allow automatic replies to emails
|
# Allow automatic replies to emails
|
||||||
|
|||||||
Reference in New Issue
Block a user