Skip to content

Update authentication components - #7

Merged
ddon merged 4 commits into
BeamLabEU:devfrom
timujinne:dev
Sep 3, 2025
Merged

Update authentication components #7
ddon merged 4 commits into
BeamLabEU:devfrom
timujinne:dev

Conversation

@timujinne

Copy link
Copy Markdown
Contributor

And some fixes of credo and dialyzer warnings

Update navigation link to point to correct live sessions page
(/phoenix_kit/admin/live_sessions) instead of the removed anonymous_sessions page.
- Fix pattern match error in phoenix_kit.update.ex by updating version patterns
- Remove unreachable pattern clause in settings_live.ex format_error_message/1
These changes resolve type checking errors and improve code correctness.
Add missing routes that were lost during merge:
- /admin/settings for Live.SettingsLive
- /admin/modules for Live.ModulesLive
These routes are needed for proper admin navigation functionality.
Update documentation to reflect all available admin routes.
…ied dev notices
- Refactor login and registration pages to minimal centered layout
- Remove hero sections and descriptive text for cleaner UX
- Simplify page titles to "Sign in" and "Create account"
- Move cross-navigation links into form footers
- Standardize all dev mode warnings with unified text and working /dev/mailbox links
- Convert MagicLink component from Tailwind to daisyUI styling for consistency
@ddon
ddon merged commit 665628b into BeamLabEU:devSep 3, 2025
ddon pushed a commit that referenced this pull request Nov 12, 2025
…tion-011CV2T4EyBP7awz91pkAzHy
Fix fragile AWS message_id extraction with metrics and debugging
ddon pushed a commit that referenced this pull request Nov 12, 2025
This merge brings in the latest changes from dev (V16-V21 migrations) and adds V22 migration with additional email system improvements.
## What's New in V22
### Database Schema Enhancements
- Add aws_message_id field to phoenix_kit_email_logs (nullable, unique when present)
- Add bounced_at, complained_at, opened_at, clicked_at timestamps to email_logs
- Add partial unique index on aws_message_id (WHERE aws_message_id IS NOT NULL)
- Add composite index (message_id, aws_message_id) for fast correlation
- Add composite index (email_log_id, event_type) for 10-100x faster duplicate checks
### New Tables
- phoenix_kit_email_orphaned_events - Track SQS events without matching logs
- phoenix_kit_email_metrics - Track system metrics (extraction rates, placeholder logs)
### Documentation
- Add comprehensive Message ID Strategy documentation in EmailLog module
- Explain dual ID system: message_id (internal) vs aws_message_id (provider)
- Document workflow and search priority for event correlation
## Changes from Dev Branch
The dev branch already includes many improvements that were originally planned:
- ✅ Duplicate event checks for ALL event types (PR #5)
- ✅ Template variable validation (PR #8)
- ✅ RateLimiter stub function implementations
- ✅ AWS message_id extraction improvements (PR #7)
- ✅ Placeholder email log handling (PR #6)
## Migration Path
Run `mix phoenix_kit.update` to apply V16-V22 migrations in sequence.
## Database Constraints
- message_id: UNIQUE NOT NULL (existing)
- aws_message_id: PARTIAL UNIQUE WHERE aws_message_id IS NOT NULL (new)
- Composite indexes for faster searches and event deduplication
## Backward Compatibility
All changes are backward compatible:
- Existing logs work with both message_id strategies
- New fields are nullable
- Indexes use create_if_not_exists for idempotency
ddon pushed a commit that referenced this pull request May 12, 2026
20 findings across BUG / IMPROVEMENT / NITPICK. Tier 1 follow-ups
(OAuth state phantom activity, validate_credentials rescue) and Tier 2
(docstring drift, Permissions "db" precedence, V114 SQL guard, form
component migration). The trivial fixes (#2 doc rename, #3 rescue
narrow, #7 3-row test, #8 comment, #11 shadow, #14 disable-with)
are addressed in the preceding commit; remaining items are flagged
for a future sweep.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ddon pushed a commit that referenced this pull request May 12, 2026
Code (PR #537 review items addressed):
- #1 BUG-MEDIUM: wrap `Annotations.delete/1` in `Repo.transaction/1` so
comment-cascade + annotation-delete are atomic. Extracted into
`delete_in_transaction/1` to keep the body flat (credo depth).
- #2 BUG-MEDIUM: sweep stale `resource_type = "annotation"` claims
across 3 moduledocs (annotation.ex, v115.ex, etcher_adapter.ex). The
implementation anchors comments to the file with
`metadata.annotation_uuid` — docs now match reality.
- #5 BUG-LOW: narrow `delete_linked_comments` rescue to expected
exception classes ([DBConnection.OwnershipError, Postgrex.Error,
ArgumentError]) so logic bugs surface instead of being swallowed.
- #11 IMPROVEMENT-LOW: drop `normalize/1` — `Ecto.Changeset.cast/3`
handles both atom- and string-keyed maps natively; the helper added
silent failure-mode risk on typo'd keys.
- #12 IMPROVEMENT-LOW: drop in-repo `Code.ensure_loaded?(PhoenixKit.Annotations)`
guard in MediaBrowser — Annotations is a core module, can't be
missing.
- #19 NITPICK: drop `PhoenixKit.Modules.Storage` from
AnnotationComposer's `@compile no_warn_undefined` (it's core, not
optional — rename should fail loudly).
- #20 NITPICK: simplify `AnnotationComposerPosition.destroyed` guard.
- #21 NITPICK: fix misleading "Etcher's bootstrap uses `||` to preserve
pre-existing slots" comment — PhoenixKit's JS owns the slots.
- #8 IMPROVEMENT-MEDIUM: gettext-wrap ~17 user-facing strings in
AnnotationComposer (flash messages + heex literals + ARIA labels).
Credo / dialyzer:
- Alias `PhoenixKit.Annotations`, `PhoenixKit.Modules.Storage`,
`PhoenixKit.Modules.Storage.EtcherAdapter`, `Storage.File` so the
six "nested modules could be aliased" findings clear.
- Convert `first_attachment_thumbnail/1`'s single-clause `with` to
`case` (credo readability).
- Add PhoenixKitComments-targeted entries to .dialyzer_ignore.exs for
the annotations context + composer (optional sibling package,
guarded at runtime).
- mix.lock picks up `etcher 0.1.0` via deps.get.
mix precommit: compile → format → credo --strict → dialyzer all clean.
Deferred to original author (Alex): #3 (race), #4 (upload rollback),
#6 (authz), #7 (schema-as-source), #9 (geometry validation), #10
(configurable component id), #13/#14 (locale-aware date + traverse_errors),
plus cosmetics #15-18, #22, #23. Disposition table in CLAUDE_REVIEW.md
updated separately.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ddon pushed a commit that referenced this pull request May 12, 2026
Code (4 more PR #537 review items):
- #7 IMPROVEMENT-MEDIUM: `Annotation.adapter_writable_fields/0` exposes
the schema's `@cast_fields` (minus `file_uuid`, which the adapter
sets server-side). EtcherAdapter derives `@schema_keys` from it so a
future schema field can't drift from the adapter whitelist silently.
- #13 IMPROVEMENT-LOW: gettext-wrap the strftime format string in
`format_date` (`gettext("%b %d, %Y")`) so locales can reorder date
components (e.g. "%d %b %Y" for en-GB / fr / de).
- #14 IMPROVEMENT-LOW: route `AnnotationComposer.first_error/1` through
`PhoenixKitWeb.Components.Core.Input.translate_error/1` — gettext-aware
helper used elsewhere in the codebase that interpolates `%{count}` and
other opts properly.
- #23 NITPICK: docstring on `truncate/2` clarifying that `limit` is the
output length (incl. ellipsis), not the source length.
Docs:
- CLAUDE_REVIEW.md disposition table updated: 13 items addressed across
`b45a7a93` + this commit, 9 deferred to Alex (down from 10 — #7 took).
mix precommit: compile → format → credo --strict (0 findings) →
dialyzer (160 errors all skipped) clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ddon pushed a commit that referenced this pull request May 12, 2026
Code (PR #538#1 — carry-over from PR #536 follow-up):
- V114 down SQL: switch the collision-suffix source from
`substring(uuid::text from 1 for 8)` (UUIDv7 timestamp prefix — same
millisecond ⇒ identical prefix ⇒ duplicate suffixed keys when two+
rows collide on (provider, name)) to `substring(uuid::text from 25
for 8)` (the post-variant random tail, 32 bits of entropy ⇒ 1-in-4B
collision probability per pair). Mirrored in `run_down!` in
`v114_test.exs` since the test duplicates the SQL.
- V114 moduledoc updated to spell out the suffix source and why the
timestamp prefix was wrong.
The fix is forward-compat: systems that already ran V114.down get the
old (potentially-collided) keys; fresh installs and any future
rollback get the corrected behavior.
Docs (PR #538#6):
- AGENTS.md TODO entry for `<.draggable_list>` test coverage widened
to call out the new `:sortable_handle` axis: three branches
(`:draggable=false`, `:draggable=true + sortable_handle=nil`,
`:draggable=true + sortable_handle=".pk-drag-handle"`).
Plus a one-line `mix format` normalization in V116 (multi-line
`execute(...)` collapsed to single line).
mix precommit: compile → format → credo --strict (0 findings) →
dialyzer (160 errors all skipped) clean.
Deferred to maintainer: #2 / #3 / #5 (cosmetics on deployed
migrations), #4 (DB-level self-loop CHECK — needs a V117), #7
(`sortable_handle` typo safety — design call on boolean shape vs
JS warning).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ddon pushed a commit that referenced this pull request Aug 9, 2026
1.7.237 ships SIX PRs, not the four I had reviewed. #689 (the migration squash)
and #690 (security-p1 + the #689 review fixes) merged before this session and
had no CHANGELOG entry at all; #694 had none either.
#689 already had a CLAUDE_REVIEW.md from an earlier pass. Appended a second
pass rather than redoing it: its five mechanical findings are fixed (verified
in #690), blocker #6 is still open and still needs a database, and blocker #7
— the module ecosystem being unable to resolve 2.0 — is DISSOLVED by shipping
as a patch release. Re-verified all seven pins in /workspace: every one is
`~> 1.7.x`, which accepts 1.7.237 and rejects 2.0.0.
That matters more than it sounds, because the first pass recommended 2.0.0 and
I bumped to 1.7.237 before reading it. The override was accidental, so the
trade is now written down: 1.7.237 breaks no module but lets a below-floor host
be dragged across the floor by a routine `mix deps.update`; 2.0.0 prevents that
but makes `mix deps.get` unsatisfiable for every host running a feature module.
I think 1.7.237 is right — a refused migration with a precise remedy beats a
dependency resolver refusing to resolve — but only if the requirement is
impossible to miss, so the CHANGELOG now LEADS with it instead of listing it.
#690 reviewed clean; no new defects. Verified the pg_has_role fix (immediate
query, parameterized, absent function falls through to queue) and specifically
checked that the bridge_version fix reached every raise site — it does, because
the :ensure_current path re-raises the existing struct.
CHANGELOG now covers #689 through #694.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for freeto 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.

2 participants

@timujinne@ddon