Repository navigation
feat: remember the last sign-in method - #47
Merged
Merged
Conversation
Adds Better Auth's lastLoginMethod plugin. Cookie-only: the value has to be readable before a session exists, which is exactly when the storeInDatabase column isn't reachable, so that option would only buy analytics at the cost of a migration. Note the plugin resolves the magic link as "magic-link" (not "email"), which is what the client will match on. The web half that reads the cookie lands next. Also ignore docs/ as a whole directory instead of enumerating files — a doc added later would otherwise leak by omission, and this repo is going public.
Reads the cookie the lastLoginMethod plugin sets and names the method in a muted line above the sign-in options, so a returning user doesn't have to remember which one they used. An unrecognised method (removed provider, cookie from an older build) renders nothing rather than a half-written sentence. The hint sits outside the buttons deliberately: a badge inside one shifted its centred label out of line with the others and carried a fill that fought the primary button's. A test pins that placement so it can't be reintroduced quietly. SocialButton is extracted only to stay under the complexity ceiling — removing the badge still left AuthPage at 23 against a max of 20. Also discloses the cookie in the privacy policy: it is non-essential under GDPR and there is no consent banner to gate it behind.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||
This branch was successfully deployed
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.
Returning users had no cue which of the three sign-in methods they used last. This adds Better Auth's
lastLoginMethodplugin and surfaces it on/auth.What it does
A muted line above the sign-in options names the method:
Values are
Google,GitHub, oran email link. An unrecognised method — removed provider, or a cookie from an older build — renders nothing rather than a half-written sentence.Notes for review
Cookie-only, no
storeInDatabase. The value has to be readable before a session exists, which is exactly when the database column isn't reachable. That option would only buy analytics, at the cost of a migration.The magic-link value is
"magic-link", not"email". The plugin docs suggest wiringcustomResolveMethodfor magic links and their UI example compares against"email"— both are stale for the installed 1.6.19, which resolves/magic-link/verifynatively. Following the docs would have meant the hint silently never rendering for our primary sign-in path. Pinned by a test case.The hint sits outside the buttons deliberately. The first attempt put a badge inside the matching button; it shifted that button's centred label out of line with the others, and its fill fought the primary button's. A test asserts the hint is not inside a button so that can't come back quietly.
SocialButtonis extracted only to satisfy the complexity ceiling. Removing the badge still leftAuthPageat 23 against a max of 20. It's the one structural change to a file that otherwise just gained a caption — if you'd rather keepauth-page.tsxcloser to its original shape, the alternative is extracting the "check your email" panel instead.Privacy policy updated. The cookie is non-essential under GDPR and there's no consent banner to gate it behind, so §4 now names it, what it stores, and that clearing it costs nothing.
beforeStoreCookieis the lever if a banner ever lands.Testing
typecheck,ultracite check,knip, and the full suite all green; react-doctor--scope changedreported 100/100.Six new tests cover all three labels, the no-cookie case, an unrecognised method, and the placement decision. They mock the auth client, so the cookie round-trip is unverified by CI — worth confirming by hand that signing in with Google then signing out shows the Google line, and that a magic-link sign-in switches it to "an email link".