Doesn't support users stored in a database
Closed this issue · 7 comments
Issue
It does not appear possible to use the addon when storing users in a database.
I think it's because Redirect goes to check the user's permissions via the file method when trying to access redirects in the CP. The Redirect addon throws the following error when visiting cp/redirect/redirects
Error
BadMethodCallException
Call to undefined method App\Models\User::isSuper() (View: /Users/jaygeorge/Sites/nameofsite/vendor/rias/statamic-redirect/resources/views/redirects/index.blade.php)
It would be really handy to be able to use the addon with users stored in a database (I need to store them in the database since I'm integrating with Erin's Charge addon.
Could you share the full stacktrace of your exception? It might be that I missed a call somewhere to transform the User to the Statamic User.
It's the collapsed vendor frames I need to look at, can you share the exception?
@riasvdv its the lack of isSuper() on the user model... I'm working with the reporter here on something else so will fix it up. I think its something the developer should handle rather than you.
Hello. I have encountered this issue too and it seems the problem is a small oversight in the redirects.index
view. In controllers everywhere the current user is fetched as
$user = User::fromUser(auth()->user());
which returns as proper Statamic user class. But in the redirects.index
view file auth()->user()
is called directly and returns a default Laravel App\Models\User
class.
@if(auth()->user()->isSuper() || auth()->user()->hasPermission('create redirects'))
This model does not have access to the Statamic user's isSuper()
method.
App\Models\User
public function isSuper(): bool
{
return $this->super;
}
This should be fixed in 3.2.0!