In my controller
namespace App\Http\Controllers\Account;
use App\Http\Controllers\Controller;
class IndexController extends Controller
{
public function index()
{
$this->authorize('view', auth()->user());
return view('account.index');
}
public function update()
{
$this->authorize('update', auth()->user());
return view('account.settings');
}
}
In UserPolicy
public function view(User $user, User $model)
{
return $user->id === $model->id;
}
public function update(User $user, User $model)
{
return $user->id === $model->id;
}
This always returns a 403, even if I put return true in the action. What am I missing?
I have also tried this:
$user = User::findOrFail(auth()->user()->id);
$this->authorizeForUser(auth()->user(), 'update', $user);
With the same result.