Repository navigation
Send a password reset link instead of the password itself - #32
Merged
Merged
Conversation
Contributor
|
Thanks for this. It works as described, and I'm going to merge it. Claude tested it on a clean phpBB 3.3.19 board (PHP 8.4, SQLite). It added users through the ACP page and followed the links in the emails that were actually sent:
Two edge cases showed up. They don't block the merge. I'll fix them in a separate PR myself, so nothing more is needed from you:
Investigated and written by Claude on behalf of William Jacoby (bonelifer). |
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.
As invited in #25, and the feature originally requested in #22.
The welcome email carries the new account's password in clear text. And when
pass_complexisPASS_TYPE_ANYorPASS_TYPE_CASE— the default — the generated password is a truncatedbase64(md5(time() . $username)), so it follows from the second the account was created and the username rather than being drawn at random. The remaining two branches usemt_rand()andstr_shuffle(), both the Mersenne Twister.Password generation. All three branches are replaced by one that draws from
random_int(). It takes one character from every classvalidate_password()requires for the configuredpass_complex, fills up to 20 characters (ormin_pass_chars, whichever is larger), and shuffles by hand.generate_password()is then unused and removed.The email. Instead of
{PASSWORD}, the welcome emails carry a reset link, built the way core's "forgot password" builds it: a 32 characterreset_tokenwith an expiry, and the URL to the reset controller. The templates gain{U_RESET_PASSWORD}and{RESET_EXPIRES}; the ACP messages and the README follow.The generated password is still stored, so nothing else in the flow changes. It is simply never disclosed, and the user replaces it through the link.
Two details worth a look:
controller.helper::route(), so boards withenable_mod_rewriteget the rewritten form.route()ends inappend_sid(), which picks up$_SID; in the ACP that is set, so the link would otherwise carry the session id of the admin creating the account.$_SIDis blanked around the call. Core's own use in the UCP does not hit this, because the requester there usually has no$_SID.{RESET_EXPIRES}usesDATETIME_FORMATwith the relative-date markers stripped, so the email states an absolute date and time rather than "Tomorrow".\phpbb\user::get_token_expiration()exists from 3.3.12, andext.phpalready requires 3.3.19, so it is called directly.Only
language/enis in the repository. Translations distributed elsewhere still have aPassword: {PASSWORD}line, which will now render empty.Tested on phpBB 3.3.19 with PHP 8.3: accounts created through the ACP mask receive the link, the reset form accepts it, and the new password takes effect.