2015-12-02 40 views
2

我用模塊在我的項目如何更改Laravel 5中的默認登錄URL?

App -> 
    Modules -> 
     Admin -> 
      Http -> 
       controller 
       middleware 
       request 

我如何使用驗證,並在此中間件

authenticate.php

public function handle($request, Closure $next) 
    { 
     if ($this->auth->guest()) { 
      if ($request->ajax()) { 
       return response('Unauthorized.', 401); 
      } else { 
       // return redirect()->guest('auth/login'); 
       return redirect()->guest('admin'); 
      } 
     } 

     return $next($request); 
    } 

redirectauthenticate重定向權威性文件,在這個中間件 身份驗證文件或文件redirectauth .php

public function handle($request, Closure $next) 
    { 
     if ($this->auth->check()) { 
      // return redirect('/home'); 
      return redirect('admin/dashbord'); 
     } 

     return $next($request); 
    } 

我該如何解決這個問題?

+0

你能解釋一下你的代碼發生了什麼,你有什麼問題以及期望的是什麼? – Andrius

+1

登錄後我移動到管理員/ dashbord當我註銷並通過此路徑到URL然後我移動身份驗證/登錄。我想我繼續/管理 –

回答

1

當它出現在docs

當用戶沒有認證成功,他們將被重定向到/auth/login URI。您可以通過在AuthController定義loginPath屬性自定義失敗後的驗證重定向位置:

protected $loginPath = '/login'; 

在你的情況,你會用'/admin'代替'/login'

+0

我如何在模塊中使用它? –

+0

protected $ loginPath ='/ admin'; protected $ redirectPath ='admin/dashboard';我用這個。這是工作,但當我註銷或我通過管理員/儀表板在URL他們在auth /登錄重定向 –

+0

「AuthController」在哪裏?我使用Laravel 5.4。 – SaidbakR