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

+ 5 - 11
packages/app/src/pages/forgot-password-errors.page.tsx

@@ -12,7 +12,7 @@ import {
 } from './utils/commons';
 
 type Props = CommonProps & {
-  errorCode: forgotPasswordErrorCode
+  errorCode?: forgotPasswordErrorCode
 };
 
 const ForgotPasswordErrorsPage: NextPage<Props> = (props: Props) => {
@@ -29,6 +29,10 @@ const ForgotPasswordErrorsPage: NextPage<Props> = (props: Props) => {
                 <h1><i className="icon-lock-open large"/></h1>
                 <h2 className="text-center">{ t('forgot_password.reset_password') }</h2>
 
+                { errorCode == null && (
+                  <h3 className="text-muted">errorCode Unknown</h3>
+                )}
+
                 { errorCode === forgotPasswordErrorCode.PASSWORD_RESET_IS_UNAVAILABLE && (
                   <h3 className="text-muted">{ t('forgot_password.feature_is_unavailable') }</h3>
                 )}
@@ -76,16 +80,6 @@ export const getServerSideProps: GetServerSideProps = async(context: GetServerSi
     props.errorCode = errorCode as forgotPasswordErrorCode;
   }
 
-  // Direct access to '/forgot-password-errors' redirects to '/'
-  if (props.errorCode == null) {
-    return {
-      redirect: {
-        permanent: false,
-        destination: '/',
-      },
-    };
-  }
-
   await injectNextI18NextConfigurations(context, props, ['translation']);
 
   return {

+ 3 - 1
packages/app/src/server/routes/forgot-password.ts

@@ -53,10 +53,12 @@ type CrowiReq = Request & {
 
 // middleware to handle error
 export const handleErrorsMiddleware = (crowi: Crowi) => {
-  return (error: Error & { code: string }, req: CrowiReq, res: Response, next: NextFunction): void => {
+  return (error: Error & { code: string, statusCode: number }, req: CrowiReq, res: Response, next: NextFunction): void => {
     if (error != null) {
       const { nextApp } = crowi;
+
       req.crowi = crowi;
+      res.status(error.statusCode);
 
       nextApp.render(req, res, '/forgot-password-errors', { errorCode: error.code });
       return;