Skip to content

Commit d736547

Browse files
committed
feat: allow admin can disable the default log in form #565
1 parent 2169704 commit d736547

File tree

5 files changed

+21
-1
lines changed

5 files changed

+21
-1
lines changed

Diff for: i18n/en_US.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -1714,6 +1714,10 @@ ui:
17141714
title: Private
17151715
label: Login required
17161716
text: Only logged in users can access this community.
1717+
password_login:
1718+
title: Password login
1719+
label: Allow email and password login
1720+
text: "WARNING: If turn off, you may be unable to log in if you have not previously configured other login method."
17171721
installed_plugins:
17181722
title: Installed Plugins
17191723
plugin_link: Plugins extend and expand the functionality of Answer. You may find plugins in the <1>Answer Plugin Repository</1>.

Diff for: ui/src/common/interface.ts

+1
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,7 @@ export interface AdminSettingsLogin {
454454
login_required: boolean;
455455
allow_email_registrations: boolean;
456456
allow_email_domains: string[];
457+
allow_password_login: boolean;
457458
}
458459

459460
/**

Diff for: ui/src/pages/Admin/Login/index.tsx

+13
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ const Index: FC = () => {
4747
description: t('email_registration.text'),
4848
default: true,
4949
},
50+
allow_password_login: {
51+
type: 'boolean',
52+
title: t('password_login.title'),
53+
description: t('password_login.text'),
54+
default: true,
55+
},
5056
allow_email_domains: {
5157
type: 'string',
5258
title: t('allowed_email_domains.title'),
@@ -73,6 +79,12 @@ const Index: FC = () => {
7379
label: t('email_registration.label'),
7480
},
7581
},
82+
allow_password_login: {
83+
'ui:widget': 'switch',
84+
'ui:options': {
85+
label: t('password_login.label'),
86+
},
87+
},
7688
allow_email_domains: {
7789
'ui:widget': 'textarea',
7890
},
@@ -105,6 +117,7 @@ const Index: FC = () => {
105117
allow_email_registrations: formData.allow_email_registrations.value,
106118
allow_email_domains: allowedEmailDomains,
107119
login_required: formData.login_required.value,
120+
allow_password_login: formData.allow_password_login.value,
108121
};
109122

110123
putLoginSetting(reqParams)

Diff for: ui/src/pages/Users/Login/index.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ const Index: React.FC = () => {
4545
ucAgentInfo = ucAgent.agent_info;
4646
}
4747
const canOriginalLogin =
48-
!ucAgentInfo || ucAgentInfo.enabled_original_user_system;
48+
(!ucAgentInfo || ucAgentInfo.enabled_original_user_system) &&
49+
loginSetting.allow_password_login;
4950

5051
const [formData, setFormData] = useState<FormDataType>({
5152
e_mail: {

Diff for: ui/src/stores/loginSetting.ts

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const loginSetting = create<IType>((set) => ({
3232
login_required: false,
3333
allow_email_registrations: true,
3434
allow_email_domains: [],
35+
allow_password_login: true,
3536
},
3637
update: (params) =>
3738
set(() => {

0 commit comments

Comments
 (0)