CrestApps / laravel-code-generator

An efficient Laravel code generator, saving time by automating the creation of resources such as views, controllers, routes, migrations, languages, and form-requests. Highly flexible and customizable, it includes a cross-browser compatible template and client-side validation for application modernization.
https://laravel-code-generator.crestapps.com
MIT License
738 stars 158 forks source link

This action is unauthorized #30

Closed xentie closed 7 years ago

xentie commented 7 years ago

Environment:

Description:

I did a Fresh Install of laravel, then ran: composer require crestapps/laravel-code-generator --dev and composer update

Steps/Commands To Reproduce:

I ran: 'php artisan fields-file:create Port --names="name,updatedby,status"' 'php artisan create:resources Port --with-form-request --models-per-page=15'

Content Of The Fields-File:

I tried with and without an imported data, got the same results on saving/updating data

hitting this error:

Symfony \ Component \ HttpKernel \ Exception \ AccessDeniedHttpException This action is unauthorized.

MikeAlhayek commented 7 years ago

As per the documentation, you must edit the authorize() to return a true value. If your using laravel’s authentication system, you could pass the —with-auth option to only allow the store/update request for the authenticated users. Have a look at the documentation for the —with-form-request https://crestapps.com/laravel-code-generator/docs/2.1

To use Laravel authentication system follow this document https://laravel.com/docs/5.5/authentication

xentie commented 7 years ago

ah, you beat me to it:

just read this on documentation:

By default, the method authorize() is set to return false for your application's security. This method must be modified to return a true value for the store and update requests to be allowed. Otherwise, the request will be Forbidden When using --with-auth option, the authorize() method return Auth::check() which should always return true at this point.

Thank you so much