youyass's avatar

redirection after authenticate

"I have a page that I want to protect by applying the auth middleware to the route of this page. I configured an AuthGestionnaireController so that once a user is authenticated, they are redirected to this protected page, but after authentication, I am still redirected to the login page. I have checked all possible errors, but I can't find any."

0 likes
21 replies
Snapey's avatar

The error is possibly in your logic

youyass's avatar

@Snapey

youyass's avatar

@Snapey

Snapey's avatar

@youyass Why are you specifying the web middleware? Have you disabled it as default middleware?

Devio's avatar

"dd()" will stop execution of your code

frankhosaka's avatar

I did test your code, and i get this error: Target class [App\Http\Controllers\AFFICHAGE\AffichageController] does not exist.

youyass's avatar

@Snapey hello, no I did not disable the web middleware I had so many more solutions that I said to myself why not do it

youyass's avatar

@Snapey but with my codes that I sent before what can you advise me to solve my problem

Devio's avatar

@youyass

Route::middleware(['web'])->group

remove web middleware here as @snapey suggested and test your code again.

Also ,in the browser, inspect element then under network tab, check the HTTP responses that you get

youyass's avatar

@Devio when you check my codes can you know if there is errors

Devio's avatar

@youyass It seems ok. maybe you are not using redirect->intended(route('default')) correctly.

try:

if (!Auth::attempt($request->only(['email','password']))
      return redirect()->route('login')->withErrors(['message'=>'Invalid Credentials']);
$request->session()->regenerate();
return redirect()->route('base'));
youyass's avatar

@Devio yes i said you i checked all and there are no issues

Please or to participate in this conversation.