Support the ongoing development of Laravel.io →
Configuration Authentication Security
Last updated 1 year ago.
0

Try the filter inside Route to make sure its working or not...and post the result here

Last updated 1 year ago.
0

Sorry for the late answer, I was on holiday. This is my routes code for the controllers I would like to have an auth filter on. I want all routes except store to be auth-filtered. How would I do this in routes? I only managed to do this with auth filter in the constructor of my controller.

Route::group(array('prefix' => 'api'), function() {
	Route::resource('customers', 'CustomersController',
		array('only' => array('index', 'show', 'store', 'destroy', 'update')));
	Route::resource('tickets', 'TicketsController', 
		array('only' => array('index', 'show', 'store', 'destroy', 'update')));
	Route::resource('questions', 'QuestionsController', 
		array('only' => array('index', 'show', 'store', 'destroy', 'update')));
});

Also, I tried the constructor auth filter on another remote server (Fortrabbit) and it still doesn't work..

Last updated 1 year ago.
0

Where are you defining your Auth filter? Is this being included by your application at run time?

Last updated 1 year ago.
0

I included the filter in the constructor, as you can see in the first code example. Then codetrash suggested to put it in to my Route, but I can't seem to get it to work there. So that was the second part of my question, how to include it in my Route.

I'm just a Laravel beginner, so sorry for any stupid questions..

Last updated 1 year ago.
0

This is covered in a couple of places in the docs:

http://laravel.com/docs/routing#route-groups

http://laravel.com/docs/routing#route-filters

http://laravel.com/docs/controllers#controller-filters

You most likely would add your filter to the route group, using the 'before' option:

Route::group(array('prefix' => 'api', 'before' => 'auth'), function() {
Last updated 1 year ago.
0

Yes, I got that working, but I want the auth filter on all my resource methods except the store. I can't seem to do this:

('auth', array('except' => 'store'));

Last updated 1 year ago.
0

No one?

Last updated 1 year ago.
0

I'm having the same issue. Anyone figure it out yet?

Edit: Found it! For anyone coming from Google, see here: http://laravel.io/forum/02-15-2014-no-filter-working-on-testin...

Edit 2: Created pull request for the docs: https://github.com/laravel/docs/pull/951

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

BenSwennen benswennen Joined 17 Mar 2014

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.