I am using Sentinel for authentication. As long I am logged in, everything is working well. But when I am logged out (f.e. delete all values in the persistences table) and I am on something.blade.php and click a link that triggers a post request (please see the code snippet below), I will get forwarded to the login page. After login, I get following Laravel error: Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException
Route in web.php:
Route::post('something/{xtype}/{xid}/execute/{yid}', 'MyController@execute');
Controller logic in MyController.php:
public function execute($xtype, $xid, $yid)
{
// business logic
return back();
}
View something.blade.php:
<form action="/something///execute/" method="POST" id="y_">
{!! csrf_field() !!}
</form>
<a type="button" href="#" onClick="document.getElementById('y_').submit()">
Middleware AdminMiddleware.php:
public function handle($request, Closure $next)
{
if (Sentinel::check())
{
if (Sentinel::getUser()->roles()->first()->slug == 'admin')
{
return $next($request);
}
}
return redirect()->guest('/login')
->with(['error' => "You do not have the permission.."]);
}
}
Edit:
After login, I will run into the LoginController and following code will be executed:
return redirect()->intended($fallbackUrl);
Since I am still new to Laravel, it is hard for me to debug deep inside the framework. Any ideas/suggestions from your side?
Everything is welcome! Thanks in advance!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire