Closed NeonOdyssey closed 3 years ago
Hi @NeonOdyssey! Thanks for reporting this bug, I will need to see if I can reproduce this before I can give a useful answer. Will get back to you!
Hi I have noticed a mistake in my original post ...
PHP Version is 8.0
I have the same problem...
Auth::user()
returns null on custom middleware
@NeonOdyssey
you need to add 'web' middleware before
'middleware' => [ 'web', 'yourCustomAdminMiddleware', Protoqol\Prequel\Http\Middleware\Authorised::class, ],
this is answered here: https://github.com/Protoqol/Prequel/issues/110
@eshelsil ahhh thanks for this 😄
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle(Request $request, Closure $next)
{
$key = $request->get('kay');
$allowedKeys = config('monzurul.allowed_keys');
if (in_array($key, $allowedKeys)) {
return $next($request);
} else {
return abort(403);
}
}
Hello, I am using this kind of middleware check, but still getting the 403 status code. Any reason why ? or a possible solution?
prequel.php
file
'middleware' => [
'web',
PrequelAuthMiddleware::class,
Protoqol\Prequel\Http\Middleware\Authorised::class,
],
Hi @Xatta-Trone, it's impossible to say what the exact cause of this problem is. I'd do more debugging into the particular middleware which is giving the 403 - this could be in de 'web' middleware group as well. If in this case the supplied code is causing it, you might need to look at the if-condition. Prequel does not give out a 403 errors on a failed middleware check. Only a 404 or a 503. Hope this helps!
Describe the bug When adding a custom middleware the page will always return to the home page as if the middleware is returning false.
To Reproduce Steps to reproduce the behavior:
Expected behavior When logged in as an admin user should see the Prequel page.
Actual Behavior Returns to the main page as if the user does not have the admin role.
PHP Version
Database type
Desktop (please complete the following information):