Просмотр исходного кода

Alerts when email authentication has not been set up

Shun Miyazawa 3 лет назад
Родитель
Сommit
814c16073f

+ 1 - 0
packages/app/public/static/locales/en_US/translation.json

@@ -686,6 +686,7 @@
     "email_address_is_already_registered":"This email address is already registered.",
     "can_not_register_maximum_number_of_users":"Can not register more than the maximum number of users.",
     "email_settings_is_not_setup":"E-mail settings is not set up. Please ask the administrator.",
+    "email_authentication_is_not_enabled": "Email authentication is not enabled. Please ask the administrator.",
     "failed_to_register":"Failed to register.",
     "successfully_created":"The user {{username}} is successfully created.",
     "can_not_activate_maximum_number_of_users":"Can not activate more than the maximum number of users.",

+ 1 - 0
packages/app/public/static/locales/ja_JP/translation.json

@@ -680,6 +680,7 @@
     "email_address_is_already_registered":"このメールアドレスは既に登録されています。",
     "can_not_register_maximum_number_of_users":"ユーザー数が上限を超えたため登録できません。",
     "email_settings_is_not_setup":"E-mail 設定が完了していません。管理者に問い合わせてください。",
+    "email_authentication_is_not_enabled": "メール認証が有効になっていません。管理者に問い合わせてください。",
     "failed_to_register":"登録に失敗しました。",
     "successfully_created":"{{username}} が作成されました。",
     "can_not_activate_maximum_number_of_users":"ユーザーが上限に達したためアクティベートできません。",

+ 1 - 0
packages/app/public/static/locales/zh_CN/translation.json

@@ -688,6 +688,7 @@
 		"email_address_is_already_registered": "此电子邮件地址已注册。",
 		"can_not_register_maximum_number_of_users": "注册的用户数不能超过最大值。",
     "email_settings_is_not_setup":"邮箱设置未设置,请询问管理员。",
+    "email_authentication_is_not_enabled": "电子邮件验证未被激活, 请询问管理员。",
 		"failed_to_register": "注册失败。",
 		"successfully_created": "已成功创建用户{{username}。",
 		"can_not_activate_maximum_number_of_users": "无法激活超过最大用户数的用户。",

+ 8 - 0
packages/app/src/components/CompleteUserRegistrationForm.tsx

@@ -11,6 +11,7 @@ interface Props {
   inputs?: any,
   email: string,
   token: string,
+  isEmailAuthenticationEnabled: boolean,
 }
 
 const CompleteUserRegistrationForm: React.FC<Props> = (props: Props) => {
@@ -72,6 +73,13 @@ const CompleteUserRegistrationForm: React.FC<Props> = (props: Props) => {
       <div className="noLogin-dialog mx-auto" id="noLogin-dialog">
         <div className="row mx-0">
           <div className="col-12">
+
+            { !props.isEmailAuthenticationEnabled && (
+              <p className="alert alert-danger">
+                <span>{t('message.email_authentication_is_not_enabled')}</span>
+              </p>
+            )}
+
             <fieldset id="registration-form" disabled={disableForm}>
               <input type="hidden" name="token" value={token} />
               <div className="input-group">

+ 6 - 0
packages/app/src/pages/user-activation.page.tsx

@@ -3,6 +3,7 @@ import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
 
 import CompleteUserRegistrationForm from '~/components/CompleteUserRegistrationForm';
 import { NoLoginLayout } from '~/components/Layout/NoLoginLayout';
+import type { CrowiRequest } from '~/interfaces/crowi-request';
 import { IUserRegistrationOrder } from '~/server/models/user-registration-order';
 
 import {
@@ -12,6 +13,7 @@ import {
 type Props = CommonProps & {
   token: string
   email: string
+  isEmailAuthenticationEnabled: boolean
 }
 
 const UserActivationPage: NextPage<Props> = (props: Props) => {
@@ -20,6 +22,7 @@ const UserActivationPage: NextPage<Props> = (props: Props) => {
       <CompleteUserRegistrationForm
         token={props.token}
         email={props.email}
+        isEmailAuthenticationEnabled={props.isEmailAuthenticationEnabled}
       />
     </NoLoginLayout>
   );
@@ -38,6 +41,7 @@ async function injectNextI18NextConfigurations(context: GetServerSidePropsContex
 
 export const getServerSideProps: GetServerSideProps = async(context: GetServerSidePropsContext) => {
   const result = await getServerSideCommonProps(context);
+  const req: CrowiRequest = context.req as CrowiRequest;
 
   // check for presence
   // see: https://github.com/vercel/next.js/issues/19271#issuecomment-730006862
@@ -53,6 +57,8 @@ export const getServerSideProps: GetServerSideProps = async(context: GetServerSi
     props.token = userRegistrationOrder.token;
   }
 
+  props.isEmailAuthenticationEnabled = req.crowi.configManager.getConfig('crowi', 'security:passport-local:isEmailAuthenticationEnabled');
+
   await injectNextI18NextConfigurations(context, props, ['translation']);
 
   return {