2016-12-01 35 views
1

laravel 5重定向到前一页登录后。laravel 5重定向到后签收前一页

当我手动打一个网址,如果它不是在其redrecting登录到登录页面,但登录后应该重定向到输入的网址,但在我的情况下,它将进入主页。

代码:

public function index() 
    { 

      // Is the user logged in? 
     if (Auth::check()) 
     { 
      return Redirect::route('dashboard'); 
     } 

     // Show the page 
     return View('auth.login'); 
    } 


public function getSignin() 
    { 

      // Is the user logged in? 
     if (Auth::check()) 
     { 
      return Redirect::route('dashboard'); 
     } 

     // Show the page 
     return View('auth.login'); 
    } 
+0

或者我应该改变中间件? – user6527

+1

[Laravel可能重复登录后重定向回原始目的地](http://stackoverflow.com/questions/15389833/laravel-redirect-back-to-original-destination-after-login) – jannej

回答

0

您可以在使用的情况下,如果redirect()->back()在用户登录

+0

redirect() - > back ();不会工作,因为以前的网址将是登录页面,如果它的登录页面已经登录,它将重定向到主页... – user6527

+0

你可以在这里找到你的答案:[link](http://stackoverflow.com/questions/15389833/laravel-redirect-back-to-original-destination-after-login?noredirect = 1&lq = 1) –

+0

没有使用middelware,我们可以这样做吗? – user6527