File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ import {
20
20
} from '../../lib/graphql/post' ;
21
21
import { safe } from '../../lib/utils' ;
22
22
import PopupOKCancel from '../../components/common/PopupOKCancel' ;
23
+ import { useUserId } from '../../lib/hooks/useUser' ;
24
+ import NotFoundPage from '../../pages/NotFoundPage' ;
23
25
24
26
export type ActiveEditorProps = { } ;
25
27
@@ -29,6 +31,7 @@ const ActiveEditor: React.FC<ActiveEditorProps> = () => {
29
31
const postId = useSelector ( ( state : RootState ) => state . write . postId ) ;
30
32
const [ askLoadTemp , setAskLoadTemp ] = useState ( false ) ;
31
33
const initialized = useRef ( false ) ;
34
+ const userId = useUserId ( ) ;
32
35
33
36
const dispatch = useDispatch ( ) ;
34
37
const location = useLocation ( ) ;
@@ -128,6 +131,13 @@ const ActiveEditor: React.FC<ActiveEditorProps> = () => {
128
131
// dispatch(setInitialBody(lastPostHistory.body));
129
132
} , [ dispatch , lastPostHistory , post ] ) ;
130
133
134
+ if (
135
+ ( ! readPostForEdit . loading && post === null ) ||
136
+ ( post && post . user . id !== userId )
137
+ ) {
138
+ return < NotFoundPage /> ;
139
+ }
140
+
131
141
if ( id && ! post && ! postId ) return null ;
132
142
133
143
return (
Original file line number Diff line number Diff line change @@ -341,6 +341,9 @@ export const READ_POST_FOR_EDIT = gql`
341
341
id
342
342
name
343
343
}
344
+ user {
345
+ id
346
+ }
344
347
}
345
348
}
346
349
` ;
@@ -396,6 +399,9 @@ export type ReadPostForEditResponse = {
396
399
name : string ;
397
400
} | null ;
398
401
updated_at : string ;
402
+ user : {
403
+ id : string ;
404
+ } ;
399
405
} ;
400
406
} ;
401
407
You can’t perform that action at this time.
0 commit comments