Skip to content

Add profile settings and fix router integration#3

Merged
timujinne merged 4 commits into
BeamLabEU:mainfrom
timujinne:main
Sep 2, 2025
Merged

Add profile settings and fix router integration#3
timujinne merged 4 commits into
BeamLabEU:mainfrom
timujinne:main

Conversation

@timujinne
Copy link
Copy Markdown
Contributor

Adds user profile editing functionality and improves admin navigation

Add profile changeset function and complete profile editing interface
with first name and last name fields. Includes validation and update
handlers for improved user experience.
Remove unnecessary redirect pipe for login route and add admin
shortcut route for improved navigation. Consolidates authentication
flow and enhances admin dashboard accessibility.
Add profile settings functionality and fix router integration.
Update version references in README and add detailed changelog
entry for new features and improvements.
@timujinne timujinne merged commit bee06e3 into BeamLabEU:main Sep 2, 2025
timujinne referenced this pull request in timujinne/phoenix_kit Oct 26, 2025
## Problem #1: OAuth halt() missing (CRITICAL)
Fixed missing halt(conn) call in handle_oauth_request() that caused 500 errors
when users clicked OAuth sign-in buttons. Phoenix would attempt to render a
non-existent view template after Ueberauth processed the request.

Modified: lib/phoenix_kit_web/users/oauth.ex:105

## Problem #2: IPv6 Protocol.UndefinedError (HIGH PRIORITY)
Created centralized PhoenixKit.Utils.IpAddress module to prevent
Protocol.UndefinedError when extracting IPv6 addresses.

Root cause: Six files had duplicate extract_ip_address() functions calling
to_string(address) on IPv6 tuples without proper guard clauses. This caused:
  Protocol.UndefinedError: String.Chars not implemented for IPv6 tuples

Solution:
- Created lib/phoenix_kit/utils/ip_address.ex with proper pattern matching:
  * IPv4: {a, b, c, d} pattern with is_integer guards
  * IPv6: {a, b, c, d, e, f, g, h} pattern with is_integer guards
  * Invalid/nil: returns "unknown"

- Removed duplicate implementations from 7 files:
  * lib/phoenix_kit_web/live/dashboard.ex
  * lib/phoenix_kit_web/users/login.ex
  * lib/phoenix_kit_web/users/registration.ex
  * lib/phoenix_kit_web/users/magic_link.ex
  * lib/phoenix_kit_web/live/users/live_sessions.ex
  * lib/phoenix_kit/utils/geolocation.ex
  * lib/phoenix_kit_web/users/oauth.ex

- Updated all call sites to use IpAddress.extract_from_socket() or
  IpAddress.extract_from_conn() for consistency

## Problem #3: OAuth config not loading at startup
Already fixed in current version (integration.ex:442-463).
phoenix_kit_routes() macro spawns task that calls OAuthConfig.configure_providers()
with 100ms delay to ensure database is ready.

## Code Quality
- Fixed all Credo compilation warnings (alias ordering, number formatting)
- Comprehensive unit tests added (17 test cases covering IPv4, IPv6, edge cases)
- All tests passing
- No compilation errors or warnings
ddon pushed a commit that referenced this pull request Nov 12, 2025
Fix aws_message_id unique index to use partial index for non-NULL values
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 (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>
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