2016-08-24 83 views
-1

在LoginController.php 我想將用戶重定向到主頁,但它在驗證用戶後總是顯示空白頁面。如何在主頁中登錄身份驗證後重定向用戶?

public function authenticater($data,$request) 
    { 
     $email=$data['email']; 
     $check=User::where('email', '=',$email)->first(); 
     //if not found means we need to register the user 

     if ($check != null) { 
      // Authentication passed..... 
      $id=intval($check->id); 
      Auth::loginUsingId($id,true); 
      //echo '<html><script>setTimeout(function(){ window.history.go(-1); }, 3000);</script></html>'; 
      //echo '<html><script>location.href="/";</script></html>'; 

      return redirect()->guest(route('home')); 

     } 

回答

0

想通了, 我的錯誤是:我叫從controller.So的另一種方法authenticater(),控制正想來電者的方法。

$this->authenticater($data,$request); 
     return redirect('/home'); 

已解決。 ..

反正,我嘗試了所有這些.still謝謝@ Jahid26和@Iftikhar uddin :)

0

變化return redirect()->guest(route('home'));

return redirect('home'); 

OR

return redirect()->route('home');

,並確保您的home.blade.php在有一些數據,其他明智的,它會顯示空白頁。

0

你應該寫這個

public function authenticater($data,$request) 
    { 
     $email=$data['email']; 
     $check=User::where('email', '=',$email)->first(); 
     //if not found means we need to register the user 

     if ($check != null) { 
      // Authentication passed..... 
      $id=intval($check->id); 
      Auth::loginUsingId($id,true); 
      //echo '<html><script>setTimeout(function(){ window.history.go(-1); }, 3000);</script></html>'; 
      //echo '<html><script>location.href="/";</script></html>'; 

      return redirect()->route('profile'); 

     } 

這將解決你的問題

相關問題