Why does a 403 error occur when I log in and am forwarded to a route? However, if I enter the URL manually, the URL will be accessible
This is a middleware role with identification 1, it should be accessible with user role 1
here is the code
php artisan route:clear && php artisan route:cache
composer dump-autoload
is not working ,
public function login(Request $request)
{
$input = $request->all();
$this->validate($request, [
'identifier' => 'required',
'password' => 'required'
]);
$credentials = [
'password' => $input['password']
];
if (strpos($input['identifier'], '@') !== false) {
$credentials['email'] = $input['identifier'];
} else {
$credentials['username'] = $input['identifier'];
}
if (auth()->attempt($credentials)) {
if (auth()->user()->role === 1) {
return redirect()->route('seller.dashboard');
} else {
abort(403, 'Anda tidak memiliki akses.');
}
} else {
return redirect()->route('seller.login')->with('error', 'Email atau Password tidak sesuai.');
}
}
It should be directly forwarded to route(‘seller.dashboard’) without a 403 statement because the person logging in is role 1
2
Answers
I didn't expect that from the political parties in Indonesia, you would venture into the world of code, btw TQ Anas Urbaningrum
The auth attempt method not working properly try to troubleshoot the the attempt method.