mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-11-11 06:31:39 +00:00
feat(registration): 支持邮箱白名单后缀通配符
This commit is contained in:
1 parent
16793d3af0
commit
a5b9b68b76
11 files changed
+185
-46
No files matched your search
@@ -1415,7 +1415,6 @@
|
||||
:key="suffix"
|
||||
class="inline-flex items-center gap-1 rounded bg-gray-100 px-2 py-1 text-xs font-mono text-gray-700 dark:bg-dark-600 dark:text-gray-200"
|
||||
>
|
||||
<span class="text-gray-400 dark:text-gray-500">@</span>
|
||||
<span>{{ suffix }}</span>
|
||||
<button
|
||||
type="button"
|
||||
@@ -1436,10 +1435,6 @@
|
||||
<div
|
||||
class="flex min-w-[220px] flex-1 items-center gap-1 rounded border border-transparent px-2 py-1 focus-within:border-primary-300 dark:focus-within:border-primary-700"
|
||||
>
|
||||
<span
|
||||
class="font-mono text-sm text-gray-400 dark:text-gray-500"
|
||||
>@</span
|
||||
>
|
||||
<input
|
||||
v-model="registrationEmailSuffixWhitelistDraft"
|
||||
type="text"
|
||||
@@ -7983,8 +7978,8 @@ async function saveSettings() {
|
||||
registration_enabled: form.registration_enabled,
|
||||
email_verify_enabled: form.email_verify_enabled,
|
||||
registration_email_suffix_whitelist:
|
||||
registrationEmailSuffixWhitelistTags.value.map(
|
||||
(suffix) => `@${suffix}`,
|
||||
registrationEmailSuffixWhitelistTags.value.map((suffix) =>
|
||||
suffix.startsWith("*.") ? suffix : `@${suffix}`,
|
||||
),
|
||||
promo_code_enabled: form.promo_code_enabled,
|
||||
invitation_code_enabled: form.invitation_code_enabled,
|
||||
|
||||
@@ -164,6 +164,7 @@ import {
|
||||
import { apiClient } from '@/api/client'
|
||||
import { buildAuthErrorMessage } from '@/utils/authError'
|
||||
import {
|
||||
formatRegistrationEmailSuffixWhitelistForMessage,
|
||||
isRegistrationEmailSuffixAllowed,
|
||||
normalizeRegistrationEmailSuffixWhitelist
|
||||
} from '@/utils/registrationEmailPolicy'
|
||||
@@ -574,7 +575,10 @@ function buildEmailSuffixNotAllowedMessage(): string {
|
||||
}
|
||||
const separator = String(locale.value || '').toLowerCase().startsWith('zh') ? '、' : ', '
|
||||
return t('auth.emailSuffixNotAllowedWithAllowed', {
|
||||
suffixes: normalizedWhitelist.join(separator)
|
||||
suffixes: formatRegistrationEmailSuffixWhitelistForMessage(normalizedWhitelist, {
|
||||
separator,
|
||||
more: (count) => t('auth.emailSuffixAllowedMore', { count })
|
||||
})
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -318,6 +318,7 @@ import {
|
||||
} from '@/api/auth'
|
||||
import { buildAuthErrorMessage } from '@/utils/authError'
|
||||
import {
|
||||
formatRegistrationEmailSuffixWhitelistForMessage,
|
||||
isRegistrationEmailSuffixAllowed,
|
||||
normalizeRegistrationEmailSuffixWhitelist
|
||||
} from '@/utils/registrationEmailPolicy'
|
||||
@@ -739,7 +740,10 @@ function buildEmailSuffixNotAllowedMessage(): string {
|
||||
}
|
||||
const separator = String(locale.value || '').toLowerCase().startsWith('zh') ? '、' : ', '
|
||||
return t('auth.emailSuffixNotAllowedWithAllowed', {
|
||||
suffixes: normalizedWhitelist.join(separator)
|
||||
suffixes: formatRegistrationEmailSuffixWhitelistForMessage(normalizedWhitelist, {
|
||||
separator,
|
||||
more: (count) => t('auth.emailSuffixAllowedMore', { count })
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user