Skip to content

Stop failed sign-ins writing current_platform; fix resending orphaned invites - #149

Merged
dadachi merged 3 commits into
mainfrom
fix/sign-in-platform-and-orphan-invite
Oct 10, 2026
Merged

dadachi merged 3 commits into
mainfrom
fix/sign-in-platform-and-orphan-invite

Conversation

@dadachi

@dadachi dadachi commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Sign-in wrote current_platform even when the password was wrong. devise_token_auth finds the shopkeeper by email before checking the password, and SessionsController#create saved the source header whenever that lookup succeeded, skipping validation. Anyone knowing an email could set any string; the record then failed its ios/android inclusion check, so the shopkeeper's profile updates returned 422. The platform is now written from render_create_success (successful sign-ins only) and only for ios / android (Shopkeeper::CURRENT_PLATFORMS).
  • Resending an invitation whose inviter was deleted crashed the mail job (NoMethodError: undefined method 'name' for nil). invited_by is nullified on shopkeeper deletion; the mail now names the app (mobile_app.name) instead.
  • Clear two lint config warnings: remove the removed Style/DoubleCopDisableDirective cop from .rubocop.yml, rename .erb-lint.yml to .erb_lint.yml.

Tests

Written first and seen failing before the fix:

  • failed sign-in does not change current_platform
  • successful sign-in with an unsupported source header preserves the existing current_platform
  • invited names the app when the inviter has been deleted

bin/rubocop, bin/brakeman, erb_lint: clean. bin/rails test: 540 runs, 0 failures.

Exercised on a running dev server: a wrong-password sign-in with source: hacked left current_platform unchanged; successful sign-ins stored ios/android and ignored hacked. Rendered the invitation mail for a dev invitation with no inviter: subject "NativeAppTemplate invited you to Test org".

🤖 Generated with Claude Code

https://claude.ai/code/session_01WyUzNEPWyhjjWrBcSaXSW4

dadachi and others added 3 commits October 10, 2026 17:16
… invites

devise_token_auth looks the shopkeeper up by email before checking the
password, and SessionsController#create saved the `source` header whenever
that lookup succeeded. Anyone who knew an email could set the shopkeeper's
current_platform to any string, skipping validation; the record then failed
its ios/android inclusion check, so that shopkeeper's profile updates
returned 422. The platform is now written from render_create_success, which
runs only after a successful sign-in, and only for "ios" or "android".

Deleting an inviter nullifies accounts_invitations.invited_by_id, and
resending such an invitation raised NoMethodError on nil.name in the mail
job. The invitation mail now names the app (mobile_app.name) instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WyUzNEPWyhjjWrBcSaXSW4
Drop the Style/DoubleCopDisableDirective entry (RuboCop removed the cop)
and rename .erb-lint.yml to .erb_lint.yml, the name erb_lint now expects.
Both tools printed a warning on every run; the lint results are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WyUzNEPWyhjjWrBcSaXSW4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WyUzNEPWyhjjWrBcSaXSW4
@dadachi
dadachi merged commit d05df61 into main Oct 10, 2026
3 checks passed
@dadachi
dadachi deleted the fix/sign-in-platform-and-orphan-invite branch October 10, 2026 08:23
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.

1 participant