barryvdh / laravel-httpcache

Laravel HTTP Cache
484 stars 41 forks source link

Cannot logout #25

Open teepluss opened 8 years ago

teepluss commented 8 years ago

I cannot use auth()->logout() after at the httpcache middleware, It still logged in, so I have to modify the kernel like this.

    public function handle($request)
    {
        $ignores = [
            "login",
            "logout",
            "auth(.+)",
            "admin(.+)",
            "register",
        ];
        $pattern = implode('|', $ignores);

        // Ignore middleware from some routes.
        if (! preg_match('~'.$pattern.'~', $request->path())) {
            $this->prependMiddleware('Barryvdh\HttpCache\Middleware\ParseEsi');
            $this->prependMiddleware('Barryvdh\HttpCache\Middleware\CacheRequests');
        }

        return parent::handle($request);
    }
webkonstantin commented 8 years ago

Probably somewhat cleaner solution could be to use POST for logout – POST requests should not be cached.

See Symfony's HttpCache documentation

teepluss commented 8 years ago

Thank you, That's works!