can’t get access to admin dasheboard
in my laravel project, I specified 2 guards, 1 for users and 1 for admins.
everything was working properly and today I find out that I couldn’t log in to the admin page.
I don’t know what happened! I did not change anything!!
when I try to log in as an admin, the login page gets reloads again!
btw, for the case of users, everything works fine!
this is the code
Adminlogincontroller
<?php
namespace AppHttpControllersAdmin;
use AppHttpControllersController;
use IlluminateFoundationAuthAuthenticatesUsers;
use IlluminateHttpRequest;
use IlluminateSupportFacadesAuth;
use AppAdmin;
class AdminLoginController extends Controller
{
use AuthenticatesUsers;
protected $redirectTo = '/admin';
public function __construct()
{
$this->middleware(array('guest:admin','guest:web'))->except('logout');
}
public function login(Request $request)
{
// Validate the form data
$this->validate($request, [
'email' => 'required|email',
'password' => 'required|min:6'
]);
// Attempt to log the user in
if (Auth::guard('admin')->attempt(['email' => $request->email, 'password' => $request->password], $request->remember)) {
// if successful, then redirect to their intended location
return redirect()->intended(route('dashboard'));
}
// if unsuccessful, then redirect back to the login with the form data
return redirect()->back()->withInput($request->only('email', 'remember'));
}
public function logout(Request $request)
{
$this->guard('admin')->logout();
$request->session()->invalidate();
return redirect()->route('AdminLogin');
}
public function showLoginForm()
{
return view('Admin.admin-login');
}
protected function guard()
{
return Auth::guard('admin');
}
protected function attemptLogin(Request $request)
{
return $this->guard()->attempt(
$this->credentials($request), $request->filled('remember')
);
}
}
blade page
<form action="/admin/login" method="post">
<div class="input-field col s12">
<i class="material-icons prefix">email
</i>
<input id="icon_prefix" name="email" type="text" class="validate">
<label for="icon_prefix" style="color:#fff;">E-Mail</label>
</div>
<div class="input-field col s12">
<i class="material-icons prefix">lock</i>
<input id="icon_prefix" name="password" type="password"
class="validate">
<label for="icon_prefix" style="color:#fff;">Mot de passe</label>
</div>
<p>
<input type="checkbox" class="filled-in" id="filled-in-box" />
<label for="filled-in-box" >Se rappeler de moi?</label>
<a href="" class="right"> Mot de passe oublié </a>
</p>
<div class="row">
<div class="col s12">
<input type="submit" class="btn hoverable purple white-text" style="margin-top:30px;" value="connexion">
</div></div>
</form>
routes:php
Route::post('/admin/login', 'AdminAdminLoginController@login');
Route::get('/admin/logout', 'AdminAdminLoginController@logout');
Route::get('/admin', 'AdminAdminController@show')->name('dashboard')
from Laravel Questions and Answers https://laravelquestions.com/php/cant-get-access-to-admin-dasheboard/
via Lzo Media
No comments:
Post a Comment