Davieboy
6 months ago

This action is unauthorized

Posted 6 months ago by Davieboy

I have been completing the Laravel Forum tutorials and I am stuck at another section, been trying to find the problem for the last 4 hours but its not happening, everything was fine until i started on the authorized_users_can_delete_replies test in https://laracasts.com/series/lets-build-a-forum-with-laravel/episodes/31

My code is exactly the same as https://github.com/laracasts/Lets-Build-a-Forum-in-Laravel/commit/8a388cc022d2a6459354e033d982c52208cc5bf4 but that test keeps throwing the following error

PHPUnit 8.5.2 by Sebastian Bergmann and contributors.

........................E........                                 33 / 33 (100%)

Time: 4.07 seconds, Memory: 40.00 MB

There was 1 error:

1) Tests\Feature\ParticipateInForumTest::authorized_users_can_delete_replies
Illuminate\Auth\Access\AuthorizationException: This action is unauthorized.

/var/www/vendor/laravel/framework/src/Illuminate/Auth/Access/Response.php:119
/var/www/vendor/laravel/framework/src/Illuminate/Auth/Access/Gate.php:318
/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Auth/Access/AuthorizesRequests.php:23
/var/www/app/Http/Controllers/ThreadsController.php:117
/var/www/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:54
/var/www/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php:45
/var/www/vendor/laravel/framework/src/Illuminate/Routing/Route.php:219
/var/www/vendor/laravel/framework/src/Illuminate/Routing/Route.php:176
/var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php:681
/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:130
/var/www/vendor/uxweb/sweet-alert/src/SweetAlert/ConvertMessagesIntoSweetAlert.php:49
/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171
/var/www/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php:41
/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171
/var/www/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php:43
/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171
/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php:76
/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171
/var/www/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php:49
/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171
/var/www/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php:56
/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171
/var/www/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php:37
/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171
/var/www/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php:66
/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171
/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:105
/var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php:683
/var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php:658
/var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php:624
/var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php:613
/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:170
/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:130
/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:21
/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171
/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:21
/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171
/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php:27
/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171
/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php:63
/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171
/var/www/vendor/fideloper/proxy/src/TrustProxies.php:57
/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171
/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:105
/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:145
/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:110
/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:468
/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:373
/var/www/tests/Feature/ParticipateInForumTest.php:79

ERRORS!
Tests: 33, Assertions: 56, Errors: 1.

The database entries are not being deleted via the delete button on the reply so something somewhere is preventing it.

My app is for logged in users only so if not logged it redirects to the login page, if that has anything to do with it. the only other change different form the tutorials is the path i used, tutorial uses /replies/{$reply->id} and i have prefixed mine with /forum/replies/{$reply->id}

any help would be appreciated, save me pulling the last few remaining hairs i have left out

Please sign in or create an account to participate in this conversation.