我創建了一個名爲ADMIN_USER的新表,其中包含字段USERNAME和PASSWORD進行身份驗證,但是當我嘗試執行登錄時,Hash :: check如預期的那樣返回true,但是驗證::嘗試返回false。Laravel 5.3 Auth :: login和Auth :: loginUsingId undefined
然後我試圖記住哈希之前登錄的用戶::檢查或驗證::嘗試與錯誤的PHP回覆:呼籲未定義功能應用\ HTTP \ \控制器驗證\ loginUsingId()
而Hash :: check下的Auth:login不記得任何東西。
這裏是在LoginController中我的身份驗證方法:
public function authenticate(Request $request)
{
$data = $request->all();
$user = new User();
$user = $user->where('USERNAME' , $data['inputUsername'])->first();
Log::info($user->PASSWORD);
Log::info($data['inputPassword']);
Auth:loginUsingId($user->id);
/*
if(Auth::attempt(array('USERNAME' => $data['inputUsername'], 'PASSWORD' => $data['inputPassword']))){
return redirect($this->home);
}else{
return redirect($this->index);
}
*/
if(Hash::check($data['inputPassword'], $user->PASSWORD)){
Auth::loginUsingId($user->id);
return redirect($this->home);
}else{
return redirect($this->index);
}
}
您是否已經遷移了Laravel隨附的遷移?你的數據庫目前有哪些表? – Dom
系統是新創建的,我手動創建了ADMIN_USER表,並在User類中添加了$ table屬性,將$ fillable數組更改爲相應的列名稱 –
我是否需要更改遷移並執行一些php命令? –