InvalidArgumentException Route [登录]未定义
问题描述:
InvalidArgumentException Route [登录]未定义
我无法检测到问题。当我从中间件验证组中删除管理面板路线时,它的效果非常好。但是,通过这种路线,它通过这个例外。
这是我的路线文件。
Route::group(['middleware'=>['auth']],function(){
Route::post('/signin','[email protected]')->name("signin");
});
My controller function is :
public function postSignIn(Request $request)
{
$this->validate($request,[
'email' => 'required|email',
'password' => 'required|min:6',
]);
$email = $request['email'];
$user = User::where("email",$email)->first();
if(Auth::attempt(['email' => $request['email'],'password' => $request['password']]))
{
if ($user['verified'] == 1){
if ($user['role'] == 2) {
return redirect()->route('dashboardd');
}
else if($user['role'] == 0 && $user['blocked'] == 1){
$message = 'Your account has been blocked by admin';
return redirect()->back()->with('message',$message);
}else if($user['role'] == 1 && $user['blocked'] == 1){
$message = 'Your account has been blocked by admin';
return redirect()->back()->with('message',$message);
}
else{
return redirect()->route('news-feed');
// return view('frontend.layouts.user_login_layout',compact('posts','comments','keywords','regular'));
}
}
else
{
$message = 'Account not verified! Verify Email to activate your account';
return redirect()->route('home')->with('message',$message);
}
}else{
$message = 'Wrong Credentials , Try Again ! ';
return redirect()->back()->with('message',$message);
}
}
这些路线导致问题。这与管理面板有关。 我拥有管理员和用户的相同用户表。当我从组中删除管理面板路由时,用户可以完美登录。但是当我添加这些路线时,用户不能登录也不能管理员。
//admin-panel routes
Route::get('importExport', '[email protected]');
Route::post('importExcel', '[email protected]');
Route::post('/logicsubmit','[email protected]')->name("logicsubmit");
Route::get('/RegularUser','[email protected]')->name("RegularUser");
Route::get('/Company','[email protected]')->name("Company");
Route::post('/signup','[email protected]')->name("signup");
Route::post('/companysignup','[email protected]')->name("companysignup");
Route::get('/logout','[email protected]')->name("logout");
Route::get('/dashboardd','[email protected]')->name("dashboardd");
Route::get('/admit','[email protected]')->name("admit");
Route::get('/admin','[email protected]')->name("admin");
Route::get('/admins','[email protected]')->name("admins");
Route::get('/lock', '[email protected]')->name("lock");
Route::post('/adminsignup','[email protected]')->name("adminsignup");
Route::get('/view/{id}','[email protected]')->name("view");
Route::get('/block/{id}','[email protected]')->name("block");
Route::get('/unblock/{id}','[email protected]')->name("unblock");
Route::get('/delete/{id}','[email protected]')->name("delete");
Route::get('/Addkeywords','[email protected]')->name("Addkeywords");
Route::post('/addword','[email protected]')->name("addword");
Route::get('/editword/{id}','[email protected]')->name("editword");
Route::get('/deleteword/{id}','[email protected]')->name("deleteword");
Route::post('/updateword/{id}','[email protected]')->name("updateword");
//end of admin-panel routes
答
你得到这个错误是因为你在代码的某处使用route('login')
(可能是一个视图),但是你没有一个名字为login
的路由。
重命名signin
到login
可能会做。
Route::post('/signin','[email protected]')->name("login");
或者办理代码并替换所有呼叫路由到route('login')
route('signin')
答
就像你说的,当你删除身份验证的中间件,它工作正常,背后的原因是“权威性”而不是“/登入”寻找身份验证的路线,你可以通过使用php artisan route:list
看,如果你用“登录”路由它将正常工作。所以请将您的'/ signin'路由重命名为auth的'login',因为它是预定义的。
你能后的堆栈跟踪?此外,突出部分是造成问题。(管理路线,因为你提到) – jaysingkar
请阅读[在什么情况下我可以添加“紧急”或其他类似的短语到我的问题,以获得更快的答案? .*.com/q/326569) - 总结是,这不是解决志愿者问题的理想方式,而且可能会对获得答案产生反作用。请不要将这添加到您的问题。 – halfer
@jaysingkar我更新了我提到的问题。 – DevTaabi