PhoenixKitWeb.Live.Components.UserSettings (phoenix_kit v2.26.0)

Copy Markdown View Source

Reusable LiveComponent for user settings management.

Provides profile, email, password, and OAuth settings in a self-contained component that can be embedded in any LiveView.

Usage

<.live_component
  module={PhoenixKitWeb.Live.Components.UserSettings}
  id="user-settings"
  user={@current_user}
/>

Required assigns

  • user — the current user struct
  • id — unique component ID

Optional assigns

  • sections — list of sections to display: :identity, :custom_fields, :email, :password, :oauth, :notifications, :sessions (default: all). :profile is accepted as a legacy alias that expands to [:identity, :custom_fields]
  • email_confirm_url_fn — (token -> url) for email confirmation links (default: &Routes.url("/profile/settings/confirm-email/#{&1}"))
  • return_to — where OAuth redirect returns to (default: Routes.user_settings_path/1, i.e. /profile/settings unless the user_settings_path setting points elsewhere)
  • current_session_token — raw session token of the acting browser, used by the :sessions section to mark the current device and to keep it signed in on "sign out other sessions". Without it, no session is flagged current and "sign out others" revokes every session.

Parent notifications

Sends {:phoenix_kit_user_updated, updated_user} to the parent LiveView when user data changes (profile, avatar, email, password).

Summary

Functions

The section list rendered when a caller doesn't pass sections — does NOT include :integrations (see the module attribute comment above). A caller that wants that section appended should build on this list rather than hardcoding a copy, so the two can't drift.

Functions

default_sections()

@spec default_sections() :: [atom()]

The section list rendered when a caller doesn't pass sections — does NOT include :integrations (see the module attribute comment above). A caller that wants that section appended should build on this list rather than hardcoding a copy, so the two can't drift.