whitecube / nova-page

Static pages content management for Laravel Nova
https://whitecube.github.io/nova-page
MIT License
238 stars 41 forks source link

Nova guard Issue #10

Closed stufarquhar closed 5 years ago

stufarquhar commented 5 years ago

Seem to have an issue with signing into the Nova dashboard after adding this package. I have a guard of Admin App\Admin who has access to the dashboard, but this is the error i get.

"Method Illuminate\View\View::__toString() must not throw an exception, caught ErrorException: Argument 1 passed to Whitecube\NovaPage\NovaPagePolicy::viewAny() must be an instance of App\User, instance of App\Admin given, called in /Users/xxxxx/xxxxx/vendor/laravel/framework/src/Illuminate/Auth/Access/Gate.php on line 614"

Any thoughts??

stufarquhar commented 5 years ago

i got this working by changing the vendor file "NovaPagePolicy" which is not ideal. Is there some config around updating the model. See changes ....

namespace Whitecube\NovaPage;

use App\Admin; use Illuminate\Auth\Access\HandlesAuthorization;

class NovaPagePolicy { use HandlesAuthorization;

public function viewAny(Admin $admin)
{
    return true;
}
toonvandenbos commented 5 years ago

Hi @stufarquhar,

Thank you for opening this issue!

It's true the NovaPagePolicy class is currently not very useful, I think we could simply remove the type-hinting from the method arguments. However, shouldn't your App\Admin model extend App\User? I don't know your application of course, but this sounds like a simple and logical workaround.

I'll take a closer look at this policy issue as soon as possible. I'll probably simply remove the Gate::policy() statements since it should be the developer's choice to apply them.

toonvandenbos commented 5 years ago

NovaPagePolicy has been removed. You can now apply your own authorizations if necessary.

The update will be part of the package's next release. Meanwhile you could set "whitecube/nova-page" to "dev-master" in your composer.json.