You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I followed dev marketers tutorial to implement multiple authentication in my Laravel app. However, when i try to login as an admin it stays on the admin login page and does not go to the target page. Can someone assist on how i can gp about this issue,
The following are the is my admin controller
``<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Auth;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
class AdminLoginController extends Controller
{
use AuthenticatesUsers;
public function __construct() {
$this->middleware('guest:admin')->except('logout');
}
public function showLoginForm() {
return view('auth.admin-login');
}
public function login(Request $request) {
// validate the form data here
$this->validate($request, [
'email' => 'required|email',
'password' => 'required|min:8'
]);
// 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('admin.dashboard'));
}
return redirect()->back()->withInput($request->only('email', 'remember'));
}
}
``
and this is my route that consists of the admin related views
`` Route::prefix('admin')->group(function() {
I followed dev marketers tutorial to implement multiple authentication in my Laravel app. However, when i try to login as an admin it stays on the admin login page and does not go to the target page. Can someone assist on how i can gp about this issue,
The following are the is my admin controller
``<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Auth;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
class AdminLoginController extends Controller
{
use AuthenticatesUsers;
}
``
and this is my route that consists of the admin related views
`` Route::prefix('admin')->group(function() {
Route::get('/login', 'App\Http\Controllers\Auth\AdminLoginController@showLoginForm')->name('admin.login');
Route::post('/login', 'App\Http\Controllers\Auth\AdminLoginController@login')->name('admin.login.submit');
Route::get('/', 'App\Http\Controllers\AdminController@index')->name('admin.dashboard');;
Route::get('/{id}/',[CarsController::class, 'getCar'] )->where('id', '[0-9]+')->middleware('auth:admin');;
Route::get('/cars',[CarsController::class, 'getCars'])->middleware('auth:admin')->name('admin.cars');;;
Route::get('/create-car/',[CarsController::class, 'createCar'] )->middleware('auth:admin')->name('admin.cars');;;
Route::post('/store-car/',[CarsController::class, 'storeCar'])->middleware('auth:admin');;;
Route::get('/{id}/edit',[CarsController::class, 'editCar'])->where('id', '[0-9]+')->middleware('auth:admin');;;
Route::post('/cars/edit-car/{id}',[CarsController::class, 'storeEditedCar'])->where('id', '[0-9]+')->middleware('auth:admin');;;
});``
The text was updated successfully, but these errors were encountered: