tuupola / slim-basic-auth

PSR-7 and PSR-15 HTTP Basic Authentication Middleware
MIT License
440 stars 66 forks source link

After/Before Callbacks never called? #82

Closed theDyingMountain closed 5 years ago

theDyingMountain commented 5 years ago

In my case the after/before callbacks are never called, even after successful authorization. The response body returns "bool(true)" all the time. What i'm doing wrong?

$app->add(new Tuupola\Middleware\HttpBasicAuthentication([ "realm" => "Protected", "authenticator" => new PdoAuthenticator([ "pdo" => $pdo, "table" => "accounts", "user" => "username", "hash" => "password" ]), "after" => function ($response, $arguments) { var_dump('tt'); exit(); return $response->withHeader("X-Brawndo", "plants crave"); }

theDyingMountain commented 5 years ago

Sorry my fault.

Powers-RC commented 4 years ago

What did you do to resolve this? I am having the same issue where the after call back is not being triggered.

after" => function (Response $response, $arguments) use(&$container):  Response {
            var_dump("You entered this callback");
            $session = $container->get('Session');

            if (session_status() === PHP_SESSION_NONE){
                //12  hours
                $session->start([
                    'cookie_lifetime' => 43200,
                    'cookie_httponly' => true,
                    'cookie_secure' => true,
                    'cookie_samesite' => true,
                    'cookie_domain' => 'thenetnotebook.io'
                ]);
            }

            return $response;
        }
theDyingMountain commented 4 years ago

Sorry it's been a while. I don't remember the cause of the problem. Good luck!