What if you send them somewhere else if they aren't authorized but authenticated? Give them a 403 response code.
Multiple log ins and user roles question
I guess this is a general question but if I have the code from the user roles video from Laracasts I have this filter:
Route::filter('role', function($route, $request, $role)
{
if (Auth::guest() or ! Auth::user()->hasRole($role))
{
//redirect to admin/login
}
});
This filters if a user is a guest or if they're not authorized with the correct role, yes? Lets say that filter is in place for the general site log in. However, if I have an administrative area that I'd like to have it's own log in, for example site.com/admin (which would check for the correct role and then forwards to an log in controller) that works but it is hacky. The reason I say that is because a standard, or non-admin user, can log in under that same log in which then redirects them to site.com/admin -> site.com/admin/login and creates a redirect loop. Is there a second filter that I can put in place or maybe a simple if statement to check for this and then redirect non-admin users to a different area? For some reason my mind can't wrap its self around the logic and before I get home I'd like to have a basic understanding of what I need to do before I try it. Any advice?
Also I know things like Sentry and Entrust exist but quite frankly I'm really new and want to get the basics down before I start using other people's packages and code.
Please or to participate in this conversation.