Fix remember-me being silently broken by unrelated logins #6204

Closed
rsertelon wants to merge 1 commit from rsertelon:fix-mfa-remember-me into development
First-time contributor

Hey there.

I've been using Bookstack for several months now (as a family knowledge base) and stumbled upon the Remember Me not remembering me issue #2985

Being a developer myself, but not in PHP, and having access to Claude AI, I asked it the source of the bug. It found what seems to be the issue.

I'm not sure which policy this project has with AI usage, in any case, I've reviewed the code, and tried to make it as readable and close to guidelines as possible.

Hopefully this helps, tell me if I shouldn't have done that, or if the quality is too low, my goal isn't to take your valuable review time with a bad pull request :)

Thanks,

Hey there. I've been using Bookstack for several months now (as a family knowledge base) and stumbled upon the Remember Me not remembering me issue #2985 Being a developer myself, but not in PHP, and having access to Claude AI, I asked it the source of the bug. It found what seems to be the issue. I'm not sure which policy this project has with AI usage, in any case, I've reviewed the code, and tried to make it as readable and close to guidelines as possible. Hopefully this helps, tell me if I shouldn't have done that, or if the quality is too low, my goal isn't to take your valuable review time with a bad pull request :) Thanks,
Fix remember-me being silently broken by unrelated logins
Some checks failed
analyse-php / build (pull_request) Has been cancelled
lint-php / build (pull_request) Has been cancelled
test-migrations / build (8.2) (pull_request) Has been cancelled
test-migrations / build (8.3) (pull_request) Has been cancelled
test-migrations / build (8.4) (pull_request) Has been cancelled
test-migrations / build (8.5) (pull_request) Has been cancelled
test-php / build (8.2) (pull_request) Has been cancelled
test-php / build (8.3) (pull_request) Has been cancelled
test-php / build (8.4) (pull_request) Has been cancelled
test-php / build (8.5) (pull_request) Has been cancelled
cc76b69add
LoginService::attempt() holds a login open pending MFA/email
confirmation via auth()->attempt() + auth()->logout(). Laravel's
logout() unconditionally cycles the user's remember_token if one is
set, silently invalidating a remember-me cookie active elsewhere
(e.g. another device) whenever the user logged in anywhere without
requesting 'remember', MFA or not.

Blank the in-memory token before calling logout() so its "has an
existing token" check is false and it never touches the database,
then restore it in-memory so the real $remember value is honored
below. The probing attempt() call itself also drops 'remember' to
avoid an unnecessary token cycle on the current device.

Covered by tests/Auth/RememberMeTest.php.

Fixes #2985

Signed-off-by: Romain Sertelon <romain@sertelon.fr>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
rsertelon force-pushed fix-mfa-remember-me from cc76b69add
Some checks failed
analyse-php / build (pull_request) Has been cancelled
lint-php / build (pull_request) Has been cancelled
test-migrations / build (8.2) (pull_request) Has been cancelled
test-migrations / build (8.3) (pull_request) Has been cancelled
test-migrations / build (8.4) (pull_request) Has been cancelled
test-migrations / build (8.5) (pull_request) Has been cancelled
test-php / build (8.2) (pull_request) Has been cancelled
test-php / build (8.3) (pull_request) Has been cancelled
test-php / build (8.4) (pull_request) Has been cancelled
test-php / build (8.5) (pull_request) Has been cancelled
to fe91a960cf
Some checks failed
analyse-php / build (pull_request) Has been cancelled
lint-php / build (pull_request) Has been cancelled
test-migrations / build (8.2) (pull_request) Has been cancelled
test-migrations / build (8.3) (pull_request) Has been cancelled
test-migrations / build (8.4) (pull_request) Has been cancelled
test-migrations / build (8.5) (pull_request) Has been cancelled
test-php / build (8.2) (pull_request) Has been cancelled
test-php / build (8.3) (pull_request) Has been cancelled
test-php / build (8.4) (pull_request) Has been cancelled
test-php / build (8.5) (pull_request) Has been cancelled
2026-09-10 09:31:08 +02:00
Compare
Owner

Thanks for offering this @rsertelon.
Our guidelines when it comes to AI use can be found at https://www.bookstackapp.com/about/community-rules/#use-of-llmsai

Regardless though, from a quick look at the code changes, I don't think this would address the issue.
Fundamentally, We need to perform a more substantial revamp of the user session handling so that the remember-me is session based instead of user based, and so that we can better manage sessions overall.
For the kinds of changes needed, I'm not keen on having them provided via LLM-based PRs, or from folks without some continued experience in our codebase.

Therefore I'm going to close this off.

Thanks for offering this @rsertelon. Our guidelines when it comes to AI use can be found at https://www.bookstackapp.com/about/community-rules/#use-of-llmsai Regardless though, from a quick look at the code changes, I don't think this would address the issue. Fundamentally, We need to perform a more substantial revamp of the user session handling so that the remember-me is session based instead of user based, and so that we can better manage sessions overall. For the kinds of changes needed, I'm not keen on having them provided via LLM-based PRs, or from folks without some continued experience in our codebase. Therefore I'm going to close this off.
danb closed this pull request 2026-09-13 19:19:59 +02:00
Author
First-time contributor

Hey @danb Thanks for the AI guidelines, I'm sorry I didn't find them earlier. Thanks for your answer :)

Hey @danb Thanks for the AI guidelines, I'm sorry I didn't find them earlier. Thanks for your answer :)
rsertelon deleted branch fix-mfa-remember-me 2026-09-13 20:17:57 +02:00
Some checks failed
analyse-php / build (pull_request) Has been cancelled
lint-php / build (pull_request) Has been cancelled
test-migrations / build (8.2) (pull_request) Has been cancelled
test-migrations / build (8.3) (pull_request) Has been cancelled
test-migrations / build (8.4) (pull_request) Has been cancelled
test-migrations / build (8.5) (pull_request) Has been cancelled
test-php / build (8.2) (pull_request) Has been cancelled
test-php / build (8.3) (pull_request) Has been cancelled
test-php / build (8.4) (pull_request) Has been cancelled
test-php / build (8.5) (pull_request) Has been cancelled

Pull request closed

Sign in to join this conversation.
No description provided.