feat(admin/login): Add Email Registration and Allowed Email Domains control options
This commit is contained in:
@@ -1426,6 +1426,13 @@ ui:
|
||||
title: Membership
|
||||
label: Allow new registrations
|
||||
text: Turn off to prevent anyone from creating a new account.
|
||||
email_registration:
|
||||
title: Email registration
|
||||
label: Allow email registration
|
||||
text: Turn off to prevent anyone creating new account through email.
|
||||
allowed_email_domains:
|
||||
title: Allowed email domains
|
||||
text: Email domains that users must register accounts with. One domain per line. Ignored when empty.
|
||||
private:
|
||||
title: Private
|
||||
label: Login required
|
||||
|
||||
@@ -390,6 +390,8 @@ export interface AdminSettingsCustom {
|
||||
export interface AdminSettingsLogin {
|
||||
allow_new_registrations: boolean;
|
||||
login_required: boolean;
|
||||
allow_email_registrations: boolean;
|
||||
allow_email_domains: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,6 +22,17 @@ const Index: FC = () => {
|
||||
description: t('membership.text'),
|
||||
default: false,
|
||||
},
|
||||
allow_email_registrations: {
|
||||
type: 'boolean',
|
||||
title: t('email_registration.title'),
|
||||
description: t('email_registration.text'),
|
||||
default: true,
|
||||
},
|
||||
allow_email_domains: {
|
||||
type: 'string',
|
||||
title: t('allowed_email_domains.title'),
|
||||
description: t('allowed_email_domains.text'),
|
||||
},
|
||||
login_required: {
|
||||
type: 'boolean',
|
||||
title: t('private.title'),
|
||||
@@ -37,6 +48,15 @@ const Index: FC = () => {
|
||||
label: t('membership.label'),
|
||||
},
|
||||
},
|
||||
allow_email_registrations: {
|
||||
'ui:widget': 'switch',
|
||||
'ui:options': {
|
||||
label: t('email_registration.label'),
|
||||
},
|
||||
},
|
||||
allow_email_domains: {
|
||||
'ui:widget': 'textarea',
|
||||
},
|
||||
login_required: {
|
||||
'ui:widget': 'switch',
|
||||
'ui:options': {
|
||||
@@ -51,8 +71,20 @@ const Index: FC = () => {
|
||||
evt.preventDefault();
|
||||
evt.stopPropagation();
|
||||
|
||||
const allowedEmailDomains: string[] = [];
|
||||
if (formData.allow_email_domains.value) {
|
||||
const domainList = formData.allow_email_domains.value.split('\n');
|
||||
domainList.forEach((li) => {
|
||||
li = li.trim();
|
||||
if (li) {
|
||||
allowedEmailDomains.push(li);
|
||||
}
|
||||
});
|
||||
}
|
||||
const reqParams: Type.AdminSettingsLogin = {
|
||||
allow_new_registrations: formData.allow_new_registrations.value,
|
||||
allow_email_registrations: formData.allow_email_registrations.value,
|
||||
allow_email_domains: allowedEmailDomains,
|
||||
login_required: formData.login_required.value,
|
||||
};
|
||||
|
||||
@@ -78,6 +110,13 @@ const Index: FC = () => {
|
||||
const formMeta = { ...formData };
|
||||
formMeta.allow_new_registrations.value =
|
||||
setting.allow_new_registrations;
|
||||
formMeta.allow_email_registrations.value =
|
||||
setting.allow_email_registrations;
|
||||
formMeta.allow_email_domains.value = '';
|
||||
if (Array.isArray(setting.allow_email_domains)) {
|
||||
formMeta.allow_email_domains.value =
|
||||
setting.allow_email_domains.join('\n');
|
||||
}
|
||||
formMeta.login_required.value = setting.login_required;
|
||||
setFormData({ ...formMeta });
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ const loginSetting = create<IType>((set) => ({
|
||||
login: {
|
||||
allow_new_registrations: true,
|
||||
login_required: false,
|
||||
allow_email_registrations: true,
|
||||
allow_email_domains: [],
|
||||
},
|
||||
update: (params) =>
|
||||
set(() => {
|
||||
|
||||
Reference in New Issue
Block a user