🐛fix: Fix the issue where new whitelist email domain names cannot be added in the system settings
This commit is contained in:
@@ -81,6 +81,7 @@ const SystemSetting = () => {
|
|||||||
const [showPasswordLoginConfirmModal, setShowPasswordLoginConfirmModal] =
|
const [showPasswordLoginConfirmModal, setShowPasswordLoginConfirmModal] =
|
||||||
useState(false);
|
useState(false);
|
||||||
const [linuxDOOAuthEnabled, setLinuxDOOAuthEnabled] = useState(false);
|
const [linuxDOOAuthEnabled, setLinuxDOOAuthEnabled] = useState(false);
|
||||||
|
const [emailToAdd, setEmailToAdd] = useState('');
|
||||||
|
|
||||||
const getOptions = async () => {
|
const getOptions = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
@@ -292,6 +293,29 @@ const SystemSetting = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleAddEmail = () => {
|
||||||
|
if (emailToAdd && emailToAdd.trim() !== '') {
|
||||||
|
const domain = emailToAdd.trim();
|
||||||
|
|
||||||
|
// 验证域名格式
|
||||||
|
const domainRegex = /^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
|
||||||
|
if (!domainRegex.test(domain)) {
|
||||||
|
showError('邮箱域名格式不正确,请输入有效的域名,如 gmail.com');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查是否已存在
|
||||||
|
if (emailDomainWhitelist.includes(domain)) {
|
||||||
|
showError('该域名已存在于白名单中');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setEmailDomainWhitelist([...emailDomainWhitelist, domain]);
|
||||||
|
setEmailToAdd('');
|
||||||
|
showSuccess('已添加到白名单');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const submitWeChat = async () => {
|
const submitWeChat = async () => {
|
||||||
const options = [];
|
const options = [];
|
||||||
|
|
||||||
@@ -765,6 +789,16 @@ const SystemSetting = () => {
|
|||||||
placeholder='输入域名后回车'
|
placeholder='输入域名后回车'
|
||||||
style={{ width: '100%', marginTop: 16 }}
|
style={{ width: '100%', marginTop: 16 }}
|
||||||
/>
|
/>
|
||||||
|
<Form.Input
|
||||||
|
placeholder='输入要添加的邮箱域名'
|
||||||
|
value={emailToAdd}
|
||||||
|
onChange={(value) => setEmailToAdd(value)}
|
||||||
|
style={{ marginTop: 16 }}
|
||||||
|
suffix={
|
||||||
|
<Button theme="solid" type="primary" onClick={handleAddEmail}>添加</Button>
|
||||||
|
}
|
||||||
|
onEnterPress={handleAddEmail}
|
||||||
|
/>
|
||||||
<Button
|
<Button
|
||||||
onClick={submitEmailDomainWhitelist}
|
onClick={submitEmailDomainWhitelist}
|
||||||
style={{ marginTop: 10 }}
|
style={{ marginTop: 10 }}
|
||||||
|
|||||||
Reference in New Issue
Block a user