Support the ongoing development of Laravel.io →
Authentication Security Session
Last updated 2 years ago.
0

#push to top :)

0

Hi Deazl,

Same problem , after logout browser error to many redirect

push to top

0

You are watching videos that don't match the current version.

The guest middleware is applied to the AuthController methods except for logout. You are using getLogout. So the above posted answer (from adhadimas91) should fix that for you.

0

Hey adhadimas91 and lagbox. Thanks!

In the meanwhile I changed alot. For example I use my "own" AuthController wich is very close to the AuthController delivered with Laravel. Even I found, that I have to use the "web" middleware to get the $errors variable in Blade.

But now I have another problem I don't understand: The prefix in my Route-Group will be ignored.

<?php

Route::get('/', 'HomeController@getIndex');

Route::get('/test', function (Request $request) {
	dd(Auth::check());
});

// Plugin Stuff
Route::group(['prefix' => 'plugins', 'middleware' => 'web'], function() {
	Route::auth();

	Route::get('/', 'PluginController@getList');
	Route::get('featured', 'PluginController@getFeatured');
});

// Authentication Stuff
Route::group(['prefix' => 'auth'], function() {

	Route::get('login', 'Auth\AuthController@login');
	Route::post('login', 'Auth\AuthController@authenticate');
	Route::get('logout', 'Auth\AuthController@logout');

	Route::get('register', 'Auth\AuthController@register');
	Route::post('register', 'Auth\AuthController@store');

});

All links generated with URL::action('Controller@Method') are correct. Even for the AuthController. But when I open eg. "/auth/login" it redirects me to "/login". Even "/auth/register" will be redirected to "/login". After I took a look at the auth-Middleware I think that its his fault.

Now I think that I have to assign the guest-Middleware to "register()" and "login()". In the auth-Middleware I changed the redirect path from "login" to "auth/login". But now I get a Too-Many-Redirects error because I haven't assigned the guest-Middleware to it.

I know how to assign multiple middlewares, but how to do it with options like "only" and "exclude"? I have this:

$this->middleware('auth', ['except' => 'logout']); // After copied it, I recognized that it makes no sense.

I tried something like that but (I think) thats not working:

$this->middleware('web');
$this->middleware('guest', ['except' => 'logout']);

But now I get a TokenMismatchException :(

Here are my files:

Best regards, Deazl

Last updated 8 years ago.
0
Solution

You may not be passing a csrf token. If you have a form make sure it is adding the token field.

If you are doing the same things as the AuthController you would want the guest middleware applied to it except for the logout method.

Last updated 8 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Deazl deazl Joined 5 Jan 2016

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.