Fixes #185
@ -26,7 +26,7 @@ import {
|
|||||||
|
|
||||||
export const modRouteLoader =
|
export const modRouteLoader =
|
||||||
(ndkContext: NDKContextType) =>
|
(ndkContext: NDKContextType) =>
|
||||||
async ({ params }: LoaderFunctionArgs) => {
|
async ({ params, request }: LoaderFunctionArgs) => {
|
||||||
const { naddr } = params
|
const { naddr } = params
|
||||||
if (!naddr) {
|
if (!naddr) {
|
||||||
log(true, LogType.Error, 'Required naddr.')
|
log(true, LogType.Error, 'Required naddr.')
|
||||||
@ -51,6 +51,14 @@ export const modRouteLoader =
|
|||||||
const loggedInUserPubkey =
|
const loggedInUserPubkey =
|
||||||
(userState?.user?.pubkey as string | undefined) || getFallbackPubkey()
|
(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 {
|
try {
|
||||||
// Set up the filters
|
// Set up the filters
|
||||||
// Main mod content
|
// Main mod content
|
||||||
|
Loading…
x
Reference in New Issue
Block a user