cms
cms copied to clipboard
"You cant do this while logged in" toast after logging in
Bug description
Sometimes you see the "You cant do this while logged in" toast right after logging into the CP. This was introduced in #9053.
How to reproduce
I haven't figured out how exactly to trigger it yet, but it shows on the page directly after logging into the CP.
Logs
No response
Environment
Environment
Application Name: Statamic
Laravel Version: 10.34.2
PHP Version: 8.3.0
Composer Version: 2.6.5
Environment: local
Debug Mode: ENABLED
URL: statamic.test
Maintenance Mode: OFF
Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: NOT CACHED
Drivers
Broadcasting: pusher
Cache: statamic
Database: mysql
Logs: stack / single
Mail: log
Queue: sync
Session: file
Statamic
Addons: 0
Antlers: runtime
Stache Watcher: Enabled
Static Caching: Disabled
Version: 4.x-dev PRO (Just after 4.38.0, 3ce58cad6)
Installation
Fresh statamic/statamic site via CLI
Antlers Parser
regex (default)
Additional details
No response
Steps to recreate:
- Don't have Vite running
- Hit the site, get Vite error
- Start Vite
- Login
- Oh hey sweet toast
I cleared my browser cache and couldn't reproduce with the Vite steps but these seemed to work reliably for me:
- Go to Login page and click 'Forgotten password'
- Request password reset link
- Go back to Login page & login without resetting my password
- Toast appears 🍞
🤷♂️
A bit more digging... whenever I follow Duncan's method I get a redirectPath() of /cp/auth/password/reset inside sendLoginResponse, its coming from the referer form field in the login form.
It happens when the Login POST request has a referrer header with /cp/login.
Variant 1
- Go to login page
- Enter wrong credentials
- Submit
- Enter correct credentials
- Submit
Variant 2
- Go to login page
- Click «Forgot password»
- Click «I remember my password» to go back to login
- Enter correct credentials
What happens
POST request to login has referrer header of /cp/login.
After successful login the controller redirects back to /cp/login, then the RedirectIfAuthorized middleware detects a logged in user on the login route and redirects with error