mardi 3 mai 2016

Laravel - How to logout and display logout page when user manually enter unauthorized URL

I am beginner of laravel. I am using Role and permission concept for multiple user. If user manually enter URL which is not allow to that user then I want to logout that user.

I have successfully logout the user but display logout page in content area part not single page of login.

Please help me .

Thanks in advance ....

image snapshot enter image description here

This is my ACL Code -

public function handle($request, Closure $next, $permission = null)
    {
        if ($request->getSession()->has('user')) {
            $userObj = new \App\User;
            if ($userObj->canAccess($request->getSession()->get('user')[0]['userPerm'], $permission)) {
                return $next($request);
            }
            else{ 
                  redirect('logout')->withErrors(array('mst_error' => 'Unauthorized Access!'))->send();exit;
            }
        }
        return $request->isXmlHttpRequest() ? 
            response(json_encode(array('session_logout' => true)), 401) : 
            redirect('login')->withErrors(array('mst_error' => 'You don\'t have any active session. Please login again'));
    }



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1rgBTyB
via IFTTT

Aucun commentaire:

Enregistrer un commentaire