Repository navigation
docs: README のクラス型アクションとログインの例を直す - #137
Merged
Merged
Conversation
- クラス型 PageComponent::action() の例を <form action={...}> の形に直す。
_rosanna_action を hidden に自分で書くと _rosanna_csrf が入らず必ず 403 になる (#129)
- 同じ例の header('Location: ...'); exit; を RedirectException に置き換える
- ログインの例の描画クロージャで $error を参照で取り込む (#130)
- クラス型ページのフォーム送信が CSRF 付きで通り 303 でリダイレクトするテストを足す
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #129
Closes #130
Summary
PageComponent::action()の例は_rosanna_actionを hidden input に自分で書いていたため、FormActionRenderExtensionが_rosanna_csrfを足さず、送信が必ず 403 になっていました。README.md / README.ja.md とも<form action={$this->action([$this, 'save'])}>の形に直し、hidden を自分で書かないよう注記しました。header('Location: ...'); exit;はthrow new RedirectException('/dashboard');に置き換えました。クラス型ページにはPageContext::redirect()が無いので、それが投げる例外(Polidog\Relayer\Router\RedirectException、既定 303)を直接使います。新しい API は足していません。$errorを値で取り込んでいたので、use ($login, &$error)に直しました(example/src/Pages/login/page.psx と同じ形)。tests/Router/PageMethodHttpServerTestに、直した形のクラス型ページを実際のphp -Sで GET → POST し、_rosanna_csrfが入り、アクションが走り、303 +Location: /dashboardになることを確かめるテストを足しました。phpunit / phpstan / php-cs-fixer --dry-run はすべて通っています。
🤖 Generated with Claude Code