فهرست منبع

Receive errors when redirected

Shun Miyazawa 3 سال پیش
والد
کامیت
193a05dfb7
2فایلهای تغییر یافته به همراه17 افزوده شده و 2 حذف شده
  1. 3 2
      packages/app/src/components/LoginForm.tsx
  2. 14 0
      packages/app/src/pages/login.page.tsx

+ 3 - 2
packages/app/src/components/LoginForm.tsx

@@ -26,7 +26,8 @@ type LoginFormProps = {
   isLdapStrategySetup: boolean,
   isLdapStrategySetup: boolean,
   isLdapSetupFailed: boolean,
   isLdapSetupFailed: boolean,
   objOfIsExternalAuthEnableds?: any,
   objOfIsExternalAuthEnableds?: any,
-  isMailerSetup?: boolean
+  isMailerSetup?: boolean,
+  loginError?: IErrorV3,
 }
 }
 export const LoginForm = (props: LoginFormProps): JSX.Element => {
 export const LoginForm = (props: LoginFormProps): JSX.Element => {
   const { t } = useTranslation();
   const { t } = useTranslation();
@@ -44,7 +45,7 @@ export const LoginForm = (props: LoginFormProps): JSX.Element => {
   // For Login
   // For Login
   const [usernameForLogin, setUsernameForLogin] = useState('');
   const [usernameForLogin, setUsernameForLogin] = useState('');
   const [passwordForLogin, setPasswordForLogin] = useState('');
   const [passwordForLogin, setPasswordForLogin] = useState('');
-  const [loginErrors, setLoginErrors] = useState<IErrorV3[]>([]);
+  const [loginErrors, setLoginErrors] = useState<IErrorV3[]>(props.loginError != null ? [props.loginError] : []);
   // For Register
   // For Register
   const [usernameForRegister, setUsernameForRegister] = useState('');
   const [usernameForRegister, setUsernameForRegister] = useState('');
   const [nameForRegister, setNameForRegister] = useState('');
   const [nameForRegister, setNameForRegister] = useState('');

+ 14 - 0
packages/app/src/pages/login.page.tsx

@@ -5,9 +5,11 @@ import {
 } from 'next';
 } from 'next';
 import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
 import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
 
 
+
 import { NoLoginLayout } from '~/components/Layout/NoLoginLayout';
 import { NoLoginLayout } from '~/components/Layout/NoLoginLayout';
 import { LoginForm } from '~/components/LoginForm';
 import { LoginForm } from '~/components/LoginForm';
 import type { CrowiRequest } from '~/interfaces/crowi-request';
 import type { CrowiRequest } from '~/interfaces/crowi-request';
+import type { IErrorV3 } from '~/interfaces/errors/v3-error';
 import type { RegistrationMode } from '~/interfaces/registration-mode';
 import type { RegistrationMode } from '~/interfaces/registration-mode';
 
 
 import {
 import {
@@ -30,6 +32,7 @@ type Props = CommonProps & {
   isLdapSetupFailed: boolean,
   isLdapSetupFailed: boolean,
   isPasswordResetEnabled: boolean,
   isPasswordResetEnabled: boolean,
   isEmailAuthenticationEnabled: boolean,
   isEmailAuthenticationEnabled: boolean,
+  loginError?: IErrorV3,
 };
 };
 
 
 const LoginPage: NextPage<Props> = (props: Props) => {
 const LoginPage: NextPage<Props> = (props: Props) => {
@@ -54,6 +57,7 @@ const LoginPage: NextPage<Props> = (props: Props) => {
         isPasswordResetEnabled={props.isPasswordResetEnabled}
         isPasswordResetEnabled={props.isPasswordResetEnabled}
         isMailerSetup={props.isMailerSetup}
         isMailerSetup={props.isMailerSetup}
         registrationMode={props.registrationMode}
         registrationMode={props.registrationMode}
+        loginError={props.loginError}
       />
       />
     </NoLoginLayout>
     </NoLoginLayout>
   );
   );
@@ -120,6 +124,16 @@ export const getServerSideProps: GetServerSideProps = async(context: GetServerSi
 
 
   const props: Props = result.props as Props;
   const props: Props = result.props as Props;
 
 
+  if (context.query.loginError != null) {
+    const loginError = context.query.loginError as unknown as IErrorV3;
+    props.loginError = {
+      name: loginError.name,
+      message: loginError.message,
+      code: loginError.code,
+      args: loginError.args,
+    };
+  }
+
   injectServerConfigurations(context, props);
   injectServerConfigurations(context, props);
   injectEnabledStrategies(context, props);
   injectEnabledStrategies(context, props);
   await injectNextI18NextConfigurations(context, props, ['translation']);
   await injectNextI18NextConfigurations(context, props, ['translation']);