Repository navigation
fix(magiclink): store the link in the user's environment - #177
Merged
Merged
Conversation
/send built its token with account.NewVerification, which leaves the environment empty. The SQL stores hold env_id to a foreign key, so the insert failed and every send for a real account returned a 500. Unknown addresses still got a 200, which hid it. The memory store doesn't enforce the key, so the tests never saw it. The token now takes the user's environment, the way email verification already does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2255356 left two mfa tests with imports out of goimports order, so the Format check fails on main and on every PR. Imports only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The mfa and organization changes left eight findings that fail Lint on main and every PR. None changes behaviour: - organization: check the notification plugin's type assertion, and name authorizeInvitationChange's results. - mfa: stop the SMS override's errors shadowing the handler's err. - mfa tests: drop the dead first sid, and the parameters that only ever got one value (the rate limit, the enrolled phone), which become constants. - organization tests: the invite helper's result was never used. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Both sides cleared the same golangci-lint findings in plugins/mfa; keep main's versions, which landed with #176. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem
POST /v1/magic-link/sendreturns a 500 for every address that has an account. It builds the token withaccount.NewVerification, which leavesEnvIDempty. In the Postgres store,authsome_verifications.env_idhas a foreign key toauthsome_environments, so the insert fails:middleware.InternalErrorhides the cause, so clients only seeinternal error. Unknown addresses still get a 200, because they return before any token is made, and that hid the bug. The handler is the same in v1.10.0.Fix
The token now takes the user's environment (
v.EnvID = u.EnvID), the way email verification inservice.goalready does.Tests
TestMagicLink_Send_StoresUserEnvironmentchecks the stored token'sEnvID. The memory store doesn't enforce the foreign key, so the test checks the field directly. It fails without the fix and passes with it.go test ./plugins/magiclink/passes.Also
The Format check failed on
main: two mfa tests from 2255356 had imports out ofgoimports -local github.com/xraph/authsomeorder. A separate commit regroups them, with imports only.Lint failed on
mainfor the same reason: eight golangci-lint findings in the mfa and organization changes (errcheck, gocritic, govet shadow, ineffassign, unparam). A third commit clears them without changing behaviour.golangci-lint runon the whole repo reports 0 issues.🤖 Generated with Claude Code