You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
Hello, forgive my English... I'm using slim 4 and raintpl, authenticating through cookies. Route authentication is perfect. My problem is when authentication fails, I need to redirect to the login route and I don't see how. I tried putting a "header("Location: /login/301")", but it didn't work.
Could you help me, please?
use \Dotenv\Dotenv;
use \Slim\Factory\AppFactory;
use \Click\Model\User;
use \Click\middlewares\authenticateMiddleware;
$env = Dotenv::createImmutable(__DIR__);
$env->load();
$app = AppFactory::create();
$app->addErrorMiddleware(true, true, true);
$app->add(authenticateMiddleware::jwtAuth());
<?php
namespace Click\middlewares;
use \Psr\Http\Message\ResponseInterface as Response;
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Tuupola\Middleware\JwtAuthentication;
class authenticateMiddleware
{
public static function jwtAuth(): JwtAuthentication
{
return new JwtAuthentication([
"secure" => true,
"relaxed" => ["localhost"],
"path" => ["/admin"],
"cookie" => "tkn",
"secret" => getenv('JWT_SECRET'),
"error" => function ($response, $arguments) {
$data["status"] = "error";
$data["message"] = $arguments["message"];
header("Location: /login/301");
}
]);
}
}
?>
The text was updated successfully, but these errors were encountered:
Hello, forgive my English... I'm using slim 4 and raintpl, authenticating through cookies. Route authentication is perfect. My problem is when authentication fails, I need to redirect to the login route and I don't see how. I tried putting a "header("Location: /login/301")", but it didn't work.
Could you help me, please?
The text was updated successfully, but these errors were encountered: