0

Zend Expresive 3 を使用しています。2 つのハンドルがあり、1 つはログイン ページのレンダリング用です。

public function handle(ServerRequestInterface $request) : ResponseInterface
{
    return new HtmlResponse($this->renderer->render('web::login-page'));
}

2 つ目は、ログイン資格情報を確認するためのものです。

public function handle(ServerRequestInterface $request): ResponseInterface
{
    $params = $request->getParsedBody();
    $isPasswordCorrect = $this->authenticationAPI->checkLogin($params);

    if ($isPasswordCorrect) {
        return new RedirectResponse($this->router->generateUri('user-logged'));
    }

    return new RedirectResponse($this->router->generateUri('login-page'));
}

ユーザーが間違ったパスワードを渡した場合、ログインページにリダイレクトします。使用されているユーザー名やエラー メッセージなど、この 2 つのハンドラーの間に追加のパラメーターを追加したいと思います。それを行う最良の方法は何ですか?属性を持つリクエスト オブジェクトを生成し、それをユーザーに送信できますか (Zend Expresive 3 で行う方法)? または、ヘッダーまたはセッションを使用しますか? - しかし、それは良い考えではないと思います。

4

0 に答える 0