I have this code:
public function postLogin(Request $request) {
if(Auth::attempt(['username' => $request->username, 'password' => $request->password]))
{
return redirect()->intended('users/dashboards');
}else{
return redirect('/')->withInput()->with('message', 'Login Failed');
}
}
Here's my controller:
Route::get('/', ['as' => 'home', 'uses' => 'HomeController@Home']);
Route::post('post-login', ['as' => 'post_login', 'uses' => 'HomeController@postLogin']);
Route::group(['middleware' => 'auth', 'prefix' => 'user'], function(){
Route::get('dashboards', ['as' => 'dashboards', 'uses' => 'HomeController@getDashBoards']);
});
I don't know why it always return false. I'm testing if the user is authenticated or not. If I use Auth::check()
it returns false
but if I use Auth::guests
it return true
. I'm too confused in middleware. Can somebody help me?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1KrcJ93
via IFTTT
Aucun commentaire:
Enregistrer un commentaire