2016-11-26 23 views
0

我有來自Laravel5的Auth方法的問題。登錄後,在我的網站上,HTML文檔無法看到「我已登錄」。Laravel5 - 以Auth方法登錄後不起作用

@if(Auth::user()) 
--><li class="userNav__item"> 
     <a href="#" class="userNav__link"> 
      <i class="icon-user-add userNav__image"></i> 
      Hello, {{{ Auth::user()->name }}} 
     </a> 
    </li> 
@endif 

還有就是我的 「洛在」 控制器

public function SignIn(Request $request){ 

    if(Auth::attempt(['email'=>$request->email, 'password'=>$request->password])){ 
     return redirect('mainPage'); 
    } 
    else{ 
     return back()->withInput()->withErrors(['email' => 'Zły email lub hasło']); 
    } 
} 

而且routes.php文件文件

http://pastebin.com/68CB0r7c < - 在 「代碼」 元素不能發佈呢..

而且我的問題。爲什麼HTML文檔中的Auth方法不起作用?我究竟做錯了什麼? :(

還有一個(這很有趣...) 當我做這樣的事情

public function SignIn(Request $request){ 

    if(Auth::attempt(['email'=>$request->email, 'password'=>$request->password])){ 
     return view('layout.index'); 
     // return redirect('mainPage'); 
    } 
    else{ 
     return back()->withInput()->withErrors(['email' => 'Zły email lub hasło']); 
    } 
} 

的驗證::在HTML文檔用戶的方法工作,但是當我使用「炫魅」路由是不工作。LOL?

+0

構建你不給足夠的信息來回答這個問題。簡單地說「不起作用」是不夠的。看起來你正在使用內置身份驗證,因此請檢查日誌。 –

+0

我如何檢查日誌?對不起,這是我第一次用Laravel .. – qwerty1234567

+0

假設Laravel 5.3:'存儲/日誌/ laravel.log' –

回答

1

您的形式必須是職位,但你

炫魅路由得到

昌E - 這張貼或任何

Route::any('mainPage', function() { 
    return view('layout.index'); 
}); 

這可能會解決您的問題。

對於Laravel認證最多的就是爲你做只是看看

https://laravel.com/docs/5.2/authentication#authentication-quickstart

+0

我從這個教程做的一切,這不工作..更改爲「任何」不工作太:( – qwerty1234567

0

嘗試在你的炫魅控制器定義這樣

public function __construct() 
{ 
    $this->middleware('auth'); 
} 
+0

但我應該寫在構建我不想中間件,原因是什麼?即使沒有登錄,每個人都可以訪問每個子頁面。 – qwerty1234567