Skip to content

Admin Login redirecting back to Admin Login page.  #45

@HoodLegend

Description

@HoodLegend

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() {

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');;;

});``

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions