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

Create a separate controller and add this

public function __construct()
        {
            $this->middleware('auth');
    }

and you can uses the route

Route::get('admin/services/create',[
	'middleware' => 'auth',
	'uses' => 'ServicesController@create']);
Last updated 9 years ago.
0

I tried it, but if i try to see www.myapp.com/public for navigate my pages it redirect to www.myapp.com/public/home and gives me an error:

This webpage has a redirect loop

ERR_TOO_MANY_REDIRECTS

0

Can you post your routes file here ?

0

I'm trying on a brand new Laravel app, but i have problems anyway, if the user is NOT logged, i can navigate my pages, instead if the user IS logged, i can access only my private area, and i can't access to my other pages (in this case, my home /public), in fact if i try to go to www.myapp.com/public i am forced to be redirect to www.myapp.com/public/home, where there's my admin area.

Route::get('/', 'WelcomeController@index');
Route::get('home',['middleware' => 'auth', 'uses' => 'MiddlewareAuthController@index']);

Route::controllers([
	'auth' => 'Auth\AuthController',
	'password' => 'Auth\PasswordController',
]);
Last updated 9 years ago.
0

according to your route mysite.com/index anyone can access and mysite.com/home only logged in users

Change it

Route::get('/', 'WelcomeController@index');
Route::get('home',['middleware' => 'auth', 'uses' => 'WelcomeController@home']);

and remove this if you have in your WelcomeController

public function __construct()
        {
            $this->middleware('auth');
    }
0

Ok, this seems to works well. Just considering, if my route "home" (my private area view) and "/" (my public site) both points to WelcomeController, am i forced to use only one controller for both private and public areas?

0

Sign in to participate in this thread!

Eventy

Your banner here too?

b82 b82 Joined 12 May 2015

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.