diff --git a/src/pages/mod/loader.ts b/src/pages/mod/loader.ts index d311109..e490e65 100644 --- a/src/pages/mod/loader.ts +++ b/src/pages/mod/loader.ts @@ -26,7 +26,7 @@ import { export const modRouteLoader = (ndkContext: NDKContextType) => - async ({ params }: LoaderFunctionArgs) => { + async ({ params, request }: LoaderFunctionArgs) => { const { naddr } = params if (!naddr) { log(true, LogType.Error, 'Required naddr.') @@ -51,6 +51,14 @@ export const modRouteLoader = const loggedInUserPubkey = (userState?.user?.pubkey as string | undefined) || getFallbackPubkey() + // Check if editing and the user is the original author + // Redirect if NOT + const url = new URL(request.url) + const isEditMode = url.pathname.includes('edit-mod') + if (isEditMode && loggedInUserPubkey !== pubkey) { + return redirect(appRoutes.mods) + } + try { // Set up the filters // Main mod content