Repository navigation
Conversation
Awokein
force-pushed
the
account-body-params
branch
from
October 17, 2026 20:23
329c13a to
ac2cc5d
Compare
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.
Bunch of fixes to the account endpoints, one commit per fix so it's easy to see what changed for what.
Read account params from the request body
Login, change password, reset password, forgot password, change email and change username all read from the query string, so passwords could end up in plain text in Cloudflare/proxy logs. They now use
r.FormValue(...), which reads the body and still falls back to the query string so the current website keeps working. Also addsPOST /loginnext to theGET.Add password requirements and allow spaces
One
auth.ValidatePasswordused by register, change password and reset password: 8 to 72 characters (72 is bcrypt's limit, Go's bcrypt rejects anything longer so this gives a proper error instead of "Invalid password."). Spaces are allowed now so passphrases work. Existing passwords aren't affected, the check only runs when setting a new one.Keep the reset token when the new password is rejected
The token used to get deleted before the new password was checked, so one rejected password meant requesting a new email. It's now only deleted once the password is actually changed (or the token expired).
Make email lookups case insensitive
Emails are lowercased when registering and changing email, and lookups use a case insensitive collation so accounts saved with uppercase emails are still found. Login and forgot password now work whatever case you type, and you can't register a second account with the same email in different case.
Might be worth adding a matching index so the lookup stays fast:
db.accounts.createIndex({ email: 1 }, { collation: { locale: "en", strength: 2 } }). Any accounts that already share an email in different case would need checking by hand.Don't reject valid emails when the MX lookup fails
The email check required an MX record, so any domain without one, or a DNS lookup failing on the server, gave "Invalid email." even for real addresses. It now only rejects domains that definitely can't get mail (domain doesn't exist, or a null MX). Domains without MX records are checked for a normal address since mail falls back to that, and lookups that fail for other reasons don't block the email (register sends a confirmation email anyway). Also fixes the length check,
length < 3 && length > 254could never be true.Closes #7
Closes #9