Skip to content

Updated the comments in users_live html file, and added Modules link in dashboard.#2

Merged
ddon merged 3 commits into
BeamLabEU:devfrom
alexdont:main
Sep 1, 2025
Merged

Updated the comments in users_live html file, and added Modules link in dashboard.#2
ddon merged 3 commits into
BeamLabEU:devfrom
alexdont:main

Conversation

@alexdont
Copy link
Copy Markdown
Contributor

@alexdont alexdont commented Sep 1, 2025

No description provided.

@ddon ddon changed the base branch from main to dev September 1, 2025 20:24
@ddon ddon merged commit 5caae52 into BeamLabEU:dev Sep 1, 2025
ddon pushed a commit that referenced this pull request Sep 3, 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
timujinne referenced this pull request in timujinne/phoenix_kit Oct 29, 2025
Issue #1: Preserve Ueberauth base_path during configuration
- Function configure_ueberauth_base/0 now preserves existing base_path
- Added get_oauth_base_path/0 helper to set default based on URL prefix
- Prevents "Ueberauth plugin did not process request" error

Issue #2: Fix struct field access using bracket notation
- Replaced auth.credentials[:token] with auth.credentials.token
- Replaced auth.credentials[:refresh_token] with auth.credentials.refresh_token
- Replaced auth.extra[:raw_info] with safe get_raw_info/1 helper
- Fixes UndefinedFunctionError when OAuth callback processes response

These changes eliminate critical bugs that completely prevented OAuth
authentication with Google and other providers. Both issues were
discovered during production testing with PhoenixKit v1.4.6.

Modified files:
- lib/phoenix_kit/users/oauth_config.ex
- lib/phoenix_kit/users/oauth.ex

All quality checks passed (mix format, credo, dialyzer, test)
ddon pushed a commit that referenced this pull request Nov 12, 2025
…2MjJ7KaP1osXZbVp8ix

Claude/code review session 011 cv2 mj j7 ka p1os x zb vp8ix
mix credo --strict to verify all warnings are resolved
mdon added a commit to mdon/phoenix_kit that referenced this pull request May 5, 2026
…LOW_UP.md

Closes the one remaining MEDIUM finding from CLAUDE_REVIEW.md (BeamLabEU#2 —
hardcoded `/common/` tenant in M365 OAuth URLs that broke single-
tenant operators with AADSTS50194). Two-part fix:

1. New `interpolate_url/3` private helper in `OAuth` substitutes
   `{key}` placeholders with values from the integration's data
   (string-keyed JSONB), falling back to `oauth_config[:url_defaults]`.
   Wired into `authorization_url/5`, `exchange_code/4`, and
   `refresh_access_token/2`. URLs without `{` pass through unchanged
   (zero impact on Google / OpenRouter / Mistral / DeepSeek).

2. Microsoft provider's `auth_url` / `token_url` now use `{tenant_id}`;
   new `url_defaults: %{"tenant_id" => "common"}` preserves multi-tenant
   default behavior; new optional `tenant_id` setup field with help
   text covering the GUID / `consumers` / `organizations` options.
   Instructions panel note rewritten — operators fill in the form
   field rather than manually editing URLs.

Three pinning tests added to OAuth test suite (interpolation with a
GUID; fallback to url_defaults; backwards-compat pass-through for
URLs without placeholders). All 21 OAuth tests pass.

The other nine reviewer findings (1 MEDIUM doc, 2 LOW doc/typo,
6 NITPICKs) were addressed pre-existing or reviewer-acknowledged as
non-blocking — see FOLLOW_UP.md.
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.

2 participants