Skip to content

Add Sesion manage, whith auto log-out while role change. Live data update for admin boards whith broadcast. - #4

Closed
timujinne wants to merge 10 commits into
BeamLabEU:devfrom
timujinne:main
Closed

Add Sesion manage, whith auto log-out while role change. Live data update for admin boards whith broadcast.#4
timujinne wants to merge 10 commits into
BeamLabEU:devfrom
timujinne:main

Conversation

@timujinne

Copy link
Copy Markdown
Contributor

Add comprehensive session management system for admin interface.
Add Live update for admin pages

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.
Add profile settings and fix router integration
Implements real-time data synchronization across all admin interfaces
using isolated PubSub system for Users, Roles and Dashboard statistics.
Key features:
- PhoenixKit.PubSub.Manager: Autonomous PubSub system with lazy initialization
- PhoenixKit.Admin.Events: Centralized event broadcasting API
- Live updates for Users table (creation, updates, role changes)
- Live updates for Roles table (CRUD operations)
- Live updates for Dashboard statistics
- Graceful degradation when database unavailable
- Zero configuration - works independently of parent application
- Complete isolation from parent application PubSub
Technical implementation:
- GenServer-based PubSub manager with automatic startup
- LiveView subscriptions with handle_info event handlers
- Broadcasting integrated into Auth and Roles contexts
- Safe error handling for missing repository configuration
Testing: Comprehensive test suite validates all event types
Documentation: LIVE_UPDATES_README.md with setup and usage guide
Features:
- Complete session monitoring with active/expired session tracking
- Real-time session statistics dashboard with live updates
- Session revocation controls for individual and bulk operations
- Admin navigation integration with sessions sidebar menu
- PubSub events system for real-time session state updates
- Modern responsive UI with search, filtering, and pagination
- Security-focused design with token preview instead of full tokens
- Professional dashboard statistics cards with gradient design
Technical implementation:
- PhoenixKit.Users.Sessions context for session management
- SessionsLive component with real-time event subscriptions
- Admin events system extension for session broadcasting
- Navigation integration in admin sidebar and dashboard cards
- PostgreSQL optimized queries with proper session validation
- Role-based access control (Owner/Admin only)
- Fix alphabetical ordering of module aliases across all files
- Refactor nested function in update_user_status to reduce complexity
- Add implicit try-rescue pattern instead of explicit try blocks
- Improve module aliasing for better readability
- Remove trailing whitespace from test files
- Optimize PubSub event broadcasting for better error handling
These changes resolve all Credo warnings and improve maintainability
without affecting existing functionality.
Add automatic session termination when user roles are modified to ensure
permissions are updated immediately and prevent stale cached roles in user sessions.
- Add log_out_user_from_all_sessions/1 to PhoenixKitWeb.Users.Auth
- Add delete_all_user_session_tokens/1 and get_all_user_session_tokens/1 to Auth context
- Modify assign_role_internal/3, remove_role/2, and sync_user_roles/2 to trigger logout
- Force re-authentication after role changes for security
- Broadcast LiveView session disconnects to active user sessions
- Update role assignment tests to reflect function signature changes
This ensures role changes take effect immediately across all user sessions
and devices without requiring manual re-login prompts.
ddon pushed a commit that referenced this pull request Nov 12, 2025
…m-011CV2SuuWQoJyuCXrb426pP
Simplify message_id system architecture and add performance optimization
@ddonddon mentioned this pull request Apr 16, 2026
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>
ddon pushed a commit that referenced this pull request May 17, 2026
Add MediaGallery + MediaViewer reusable media components
ddon pushed a commit that referenced this pull request May 17, 2026
…tests, moduledoc notes, a11y
- Add `updated()` to MediaViewerDialog JS hook (mirrors PkDialog._sync) to re-assert
showModal() after LiveView patches children on prev/next step; removes asymmetry
with PkDialog that already had this guard
- Fix redundant `=== true` on `isContentEditable` in MediaViewerDialog._onKey
- Add `update/2` test coverage: current→current_uuid mapping, notify passthrough,
pre-resolved variants_map/file_structs bypass, assign_new navigation-state preservation
- Expand MediaViewer moduledoc: document `current` as initial seed (not a live tracker)
and clarify `%{}`/`[]` truthy semantics for variants_map/file_structs
- Add aria-labelledby to both <dialog> elements (MediaViewer + MediaSelectorModal),
wired to their respective h2 headings
- Verify MediaSelectorModal consumers (settings, authorization, user_form): all either
mount-gate or rely on PkDialog data-show correctly; no regressions found
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ddon pushed a commit that referenced this pull request May 17, 2026
ddon pushed a commit that referenced this pull request May 18, 2026
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.

1 participant

@timujinne