How to close with logout?

1

How can I do so that when logging out with route (logout) and the user presses the back button, it is not returned and redirected to the login?

Note: I am working with oauth in laravel 5.5

    
asked by Gino Lopez 22.03.2018 в 17:35
source

2 answers

1

Try to put this on your login page before the closing tag of the body

<script>
    var url = document.URL;
    history.pushState(null, null, document.URL);
    window.addEventListener('popstate', function () {
        history.pushState(null, null, url);
    });
</script>

What you get with this code is that when you press the back button you do not have the default behavior but you overwrite the directions to where it should have gone and put the current one, that is, the login.

    
answered by 22.03.2018 в 17:44
0

Does not Laravel do it by default with a middleware?

I have never encountered this problem, I always use a middleware like this for these "protected" routes:

if (Auth::guard($guard)->guest()) {
    if ($request->ajax()) {
        return response('Unauthorized.', 401);
    } else {
        return redirect()->guest('entrar');
    }
}
    
answered by 22.03.2018 в 17:47