jeudi 24 septembre 2015

Multiple Login Screens and Namespaces

I have a problem I can't figure out, in my application I have two login screens, one for the admin the other for the regular user. These login screens however point to the same controller in the same Auth namespace aside from that I have separated the rest of my controllers and routes into two namespaces; FrontEnd Namespace and BackEnd namespace.

Now my issue right now is when a regular user uses their credentials to login from the backend they are allowed access, I installed this package kodein/acl to handle roles and permissions and it seems to be working because when a user logs in to the backend now they can't do anything. The problem now is that even though they can't do anything they are still able to redirect to admin dashboard.

What I want here is this; when a regular user tries to login to admin backend they are denied access. I am a bit confused, i dunno how to o about it.

Do I have to create separate auth controllers and methods in both namespaces? Is that even possible? How would i go about it?

I use AngularJS for my frontend so in my route file i have this:

Route::group(['domain' => 'admin.website.loc'], function() {
    Route::any('{url?}', function($url) {
        return view('backend.index');
    })->where(['url' => '[-a-zA-Z0-9/]+']);
});


Route::any('{url?}', function($url) {
    return view('frontend.index');
})->where(['url' => '[-a-zA-Z0-9/]+']);

Which catch all urls and return to a single Index page,on the front end since i use JWT for authentication it validates the token on the frontend and if invalid or not available takes the user to the login page.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire