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

Hmmm,

In controller

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

in your middleware:

		if ($this->auth->guest())
		{
			if ($request->ajax())
			{
				return response('Unauthorized.', 401);
			}
			else
			{
				if ( Config::get('general.require_login') === true) {
					return redirect()->guest('auth/login');
				}
				return redirect()->guest('/');
			}
		}

I'd take a look at a few starter / bootstrap apps that people have put up on github. https://github.com/bestmomo/laravel5-example

I learned a lot by looking at other people's solutions.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

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.