This is an automated email from the ASF dual-hosted git repository.

shuai pushed a commit to branch feat/1.2.1/ui
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git


The following commit(s) were added to refs/heads/feat/1.2.1/ui by this push:
     new d7365477 feat: allow admin can disable the default log in form #565
d7365477 is described below

commit d7365477257be6425c78503b7f772f0b8fa123b2
Author: shuai <[email protected]>
AuthorDate: Tue Nov 14 11:28:56 2023 +0800

    feat: allow admin can disable the default log in form #565
---
 i18n/en_US.yaml                    |  4 ++++
 ui/src/common/interface.ts         |  1 +
 ui/src/pages/Admin/Login/index.tsx | 13 +++++++++++++
 ui/src/pages/Users/Login/index.tsx |  3 ++-
 ui/src/stores/loginSetting.ts      |  1 +
 5 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/i18n/en_US.yaml b/i18n/en_US.yaml
index 558f7863..72a7fe56 100644
--- a/i18n/en_US.yaml
+++ b/i18n/en_US.yaml
@@ -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>.
diff --git a/ui/src/common/interface.ts b/ui/src/common/interface.ts
index c5a1ee38..a148d5ab 100644
--- a/ui/src/common/interface.ts
+++ b/ui/src/common/interface.ts
@@ -454,6 +454,7 @@ export interface AdminSettingsLogin {
   login_required: boolean;
   allow_email_registrations: boolean;
   allow_email_domains: string[];
+  allow_password_login: boolean;
 }
 
 /**
diff --git a/ui/src/pages/Admin/Login/index.tsx 
b/ui/src/pages/Admin/Login/index.tsx
index ed2c08a7..f2579475 100644
--- a/ui/src/pages/Admin/Login/index.tsx
+++ b/ui/src/pages/Admin/Login/index.tsx
@@ -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'),
@@ -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',
     },
@@ -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)
diff --git a/ui/src/pages/Users/Login/index.tsx 
b/ui/src/pages/Users/Login/index.tsx
index 518f5b38..549808bd 100644
--- a/ui/src/pages/Users/Login/index.tsx
+++ b/ui/src/pages/Users/Login/index.tsx
@@ -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: {
diff --git a/ui/src/stores/loginSetting.ts b/ui/src/stores/loginSetting.ts
index c692915d..15d572f1 100644
--- a/ui/src/stores/loginSetting.ts
+++ b/ui/src/stores/loginSetting.ts
@@ -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(() => {

Reply via email to