Skip to content

Commit

Permalink
feat: allow admin can disable the default log in form #565
Browse files Browse the repository at this point in the history
  • Loading branch information
shuashuai committed Nov 14, 2023
1 parent 2169704 commit d736547
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
4 changes: 4 additions & 0 deletions i18n/en_US.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1714,6 +1714,10 @@ ui:
title: Private
label: Login required
text: Only logged in users can access this community.
password_login:
title: Password login
label: Allow email and password login
text: "WARNING: If turn off, you may be unable to log in if you have not previously configured other login method."
installed_plugins:
title: Installed Plugins
plugin_link: Plugins extend and expand the functionality of Answer. You may find plugins in the <1>Answer Plugin Repository</1>.
Expand Down
1 change: 1 addition & 0 deletions ui/src/common/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ export interface AdminSettingsLogin {
login_required: boolean;
allow_email_registrations: boolean;
allow_email_domains: string[];
allow_password_login: boolean;
}

/**
Expand Down
13 changes: 13 additions & 0 deletions ui/src/pages/Admin/Login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ const Index: FC = () => {
description: t('email_registration.text'),
default: true,
},
allow_password_login: {
type: 'boolean',
title: t('password_login.title'),
description: t('password_login.text'),
default: true,
},
allow_email_domains: {
type: 'string',
title: t('allowed_email_domains.title'),
Expand All @@ -73,6 +79,12 @@ const Index: FC = () => {
label: t('email_registration.label'),
},
},
allow_password_login: {
'ui:widget': 'switch',
'ui:options': {
label: t('password_login.label'),
},
},
allow_email_domains: {
'ui:widget': 'textarea',
},
Expand Down Expand Up @@ -105,6 +117,7 @@ const Index: FC = () => {
allow_email_registrations: formData.allow_email_registrations.value,
allow_email_domains: allowedEmailDomains,
login_required: formData.login_required.value,
allow_password_login: formData.allow_password_login.value,
};

putLoginSetting(reqParams)
Expand Down
3 changes: 2 additions & 1 deletion ui/src/pages/Users/Login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ const Index: React.FC = () => {
ucAgentInfo = ucAgent.agent_info;
}
const canOriginalLogin =
!ucAgentInfo || ucAgentInfo.enabled_original_user_system;
(!ucAgentInfo || ucAgentInfo.enabled_original_user_system) &&
loginSetting.allow_password_login;

const [formData, setFormData] = useState<FormDataType>({
e_mail: {
Expand Down
1 change: 1 addition & 0 deletions ui/src/stores/loginSetting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const loginSetting = create<IType>((set) => ({
login_required: false,
allow_email_registrations: true,
allow_email_domains: [],
allow_password_login: true,
},
update: (params) =>
set(() => {
Expand Down

0 comments on commit d736547

Please sign in to comment.