2017-08-27 43 views
0

enter image description hereInvalidArgumentException 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 
+0

你能後的堆棧跟蹤?此外,突出部分是造成問題。(管理路線,因爲你提到) – jaysingkar

+0

請閱讀[在什麼情況下我可以添加「緊急」或其他類似的短語到我的問題,以獲得更快的答案? .stackoverflow.com/q/326569) - 總結是,這不是解決志願者問題的理想方式,而且可能會對獲得答案產生反作用。請不要將這添加到您的問題。 – halfer

+0

@jaysingkar我更新了我提到的問題。 – DevTaabi

回答

1

你得到這個錯誤是因爲你在代碼的某處使用route('login')(可能是一個視圖),但是你沒有一個名字爲login的路由。

重命名signinlogin可能會做。

Route::post('/signin','[email protected]')->name("login"); 

或者辦理代碼並替換所有呼叫路由到route('login')route('signin')

+0

當我改變登錄登錄,它給RouteCollection-> methodNotAllowed(array('POST'))RouteCollection.php(行238) – DevTaabi

+0

這個錯誤MethodNotAllowedHttpException您需要用返回登錄視圖的'GET'路線替換這條路線。 – devk

+0

仍然存在問題未解決 – DevTaabi

0

就像你說的,當你刪除身份驗證的中間件,它工作正常,背後的原因是「權威性」而不是「/登入」尋找身份驗證的路線,你可以通過使用php artisan route:list看,如果你用「登錄」路由它將正常工作。所以請將您的'/ signin'路由重命名爲auth的'login',因爲它是預定義的。

+0

是的我使用登錄路線而不是登錄,但它工作正常時,我刪除管理路線 – DevTaabi

+0

當你在內部登錄它調用登錄路由。所以你可以使用登錄名來重命名它,或者你可以添加額外的路由爲Route :: post('login','userController @ postSignIn'); –

+0

當我更改登錄登錄時,它在RouteCollection-> methodNotAllowed(array('POST'))給RouteCollection.php(第238行) 上的MethodNotAllowedHttpException(行238) – DevTaabi

相關問題