Browse Source

feat: refactor user page access control logic for clarity

Shun Miyazawa 2 months ago
parent
commit
22269f0389
1 changed files with 17 additions and 16 deletions
  1. 17 16
      apps/app/src/pages/share/[[...path]]/page-data-props.ts

+ 17 - 16
apps/app/src/pages/share/[[...path]]/page-data-props.ts

@@ -73,24 +73,25 @@ export const getPageDataForInitial = async (
   }
 
   const disableUserPages = configManager.getConfig('security:disableUserPages');
-  if (disableUserPages) {
-    const pagePath = pageWithMeta.data.path;
-    if (isUserPage(pagePath) || isUsersTopPage(pagePath)) {
-      return {
-        props: {
-          isNotFound: true,
-          pageWithMeta: {
-            data: null,
-            meta: {
-              isNotFound: true,
-              isForbidden: true,
-            },
+  if (
+    disableUserPages &&
+    (isUserPage(pageWithMeta.data.path) ||
+      isUsersTopPage(pageWithMeta.data.path))
+  ) {
+    return {
+      props: {
+        isNotFound: true,
+        pageWithMeta: {
+          data: null,
+          meta: {
+            isNotFound: true,
+            isForbidden: true,
           },
-          isExpired: undefined,
-          shareLink: undefined,
         },
-      };
-    }
+        isExpired: undefined,
+        shareLink: undefined,
+      },
+    };
   }
 
   // expired