I'm using laravel 5.1. In my controller I use the following login method:
public function postLogin(Request $request)
{
$email = $request->input('email');
$password = $request->input('password');
if (Auth::attempt(['email' => $email, 'password' => $password])) {
return redirect()->intended('admin/dashboard');
}
return redirect('/login')->withErrors([
'email' => 'These credentials do not match our records.']);
}
My route:
Route::get('admin/dashboard', 'AdminController@index');
My controller:
public function index()
{
return view("Admin::index");
}
This works and redirects me to the index view after login. When the user is not logged in, it is still possible to access the index view by accessing the url: localhost/admin/dashboard.
How can I redirect the user to a custom page which shows an error to the user that it is not possible to access the url localhost/admin/dashboard when he is not logged in?
Any ideas? Thank you
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1UsJxBc
via IFTTT
Aucun commentaire:
Enregistrer un commentaire