@@ -200,22 +200,8 @@ public function create(Request $request): \Illuminate\Http\Response
200200
201201 public function delete (Request $ request ): \Illuminate \Http \JsonResponse
202202 {
203- $ user = $ request ->user ();
204-
205- $ request ->validate ([
206- 'wiki ' => 'required|numeric ' ,
207- ]);
208-
209- $ wikiId = $ request ->input ('wiki ' );
210- $ userId = $ user ->id ;
211203 $ wikiDeletionReason = $ request ->input ('deletionReasons ' );
212-
213- // Check that the requesting user manages the wiki
214- if (WikiManager::where ('user_id ' , $ userId )->where ('wiki_id ' , $ wikiId )->count () !== 1 ) {
215- // The deletion was requested by a user that does not manage the wiki
216- return response ()->json ('Unauthorized ' , 401 );
217- }
218- $ wiki = Wiki::find ($ wikiId );
204+ $ wiki = $ request ->attributes ->get ('wiki ' );
219205
220206 if (isset ($ wikiDeletionReason )){
221207 //Save the wiki deletion reason
@@ -231,25 +217,11 @@ public function delete(Request $request): \Illuminate\Http\JsonResponse
231217 // TODO should this just be get wiki?
232218 public function getWikiDetailsForIdForOwner (Request $ request ): \Illuminate \Http \Response
233219 {
234- $ user = $ request ->user ();
235-
236- $ wikiId = $ request ->input ('wiki ' );
237-
238- // TODO general check to make sure current user can manage the wiki
239- // this should probably be middle ware?
240- // TODO only do 1 query where instead of 2?
241- $ test = WikiManager::where ('user_id ' , $ user ->id )
242- ->where ('wiki_id ' , $ wikiId )
243- ->first ();
244- if (! $ test ) {
245- abort (403 );
246- }
247-
248- $ wiki = Wiki::where ('id ' , $ wikiId )
249- ->with ('wikiManagers ' )
250- ->with ('wikiDbVersion ' )
251- ->with ('wikiLatestProfile ' )
252- ->with ('publicSettings ' )->first ();
220+ $ wiki = $ request ->attributes ->get ('wiki ' )
221+ ->with ('wikiManagers ' )
222+ ->with ('wikiDbVersion ' )
223+ ->with ('wikiLatestProfile ' )
224+ ->with ('publicSettings ' )->first ();
253225
254226 $ res = [
255227 'success ' => true ,
0 commit comments