Repository navigation
[6.x] Redirect control panel logins to the control panel - #20018
Conversation
The control panel login form generated its action from the attemptLogin controller action, which also backs the front-end login path and actions/users/login. It could resolve to one of those, so the login wasn't a control panel request and redirected to the front end. Control panel login forms now post to the named control panel login route. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
📚 Storybook previews@craftcms/ui — open Storybook No changed components detected in this Storybook. resources/js — open Storybook No changed components detected in this Storybook. |
# Conflicts: # CHANGELOG.md
|
This PR had conflicts with Claude's response
|
# Conflicts: # CHANGELOG.md
|
This PR had conflicts with Claude's response
|
Description
attemptLoginbacks three routes (CPlogin, the front-endloginPath,actions/users/login), so the CP login form's action, generated from the controller action, could resolve to a front-end route. That POST isn't a CP request, so the login redirected to the site'spostLoginRedirectinstead ofgetPostCpLoginRedirect().The CP login POST route is now named
craft.cp.login.attempt, and the CP login page, the login modal, and the elevated-session modal post to it. Front-end login forms are unchanged.Evidence
Before:
LoginControllerTest› control panel logins post to the control panel and redirect to the post-CP-login redirectAfter: the form posts to the CP login URL, and a form login redirects to
cp_url(postCpLoginRedirect)✓ (auth and user tests: 436 passed)Before: the CP login form on a site with a front-end
loginPathposted tohttps://craft6.ddev.site/logmein, and logging in landed on the front end.After: it posts to
https://craft6.ddev.site/cp/login.🤖 Generated with Claude Code