Skip to content

Account fixes - #11

Open
Awokein wants to merge 5 commits into
MeteorDevelopment:masterfrom
Awokein:account-body-params
Open

Awokein wants to merge 5 commits into
MeteorDevelopment:masterfrom
Awokein:account-body-params

Conversation

@Awokein

@Awokein Awokein commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

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 adds POST /login next to the GET.

Add password requirements and allow spaces
One auth.ValidatePassword used 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 > 254 could never be true.

Closes #7
Closes #9

@Awokein
Awokein force-pushed the account-body-params branch from 329c13a to ac2cc5d Compare October 17, 2026 20:23
@Awokein Awokein changed the title Read account params from the request body and add password requirements Account fixes Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid E-Mail error on valid email The emails are case sensitive

1 participant