# Petal Pro Documentation
# https://petal.build/petal-pro
# This file contains all Petal Pro documentation concatenated for LLM consumption.
# Individual pages available at /petal-pro/raw/{path}
# Page index available at /petal-pro/docs.json
# What is Petal Pro?
# Source: https://petal.build/petal-pro
# What is Petal Pro?
[Petal Pro](https://petal.build) is a Phoenix boilerplate template with the goal of drastically reducing your time from a new project to a production-ready web application.
We've worked on web applications for over a decade now. PHP, Ruby on Rails, Backbone JS, React, Meteor JS, Ember JS, and now Phoenix. Having built and deployed a number of Phoenix apps into the wild ([Kindly](https://www.kindlyapp.com.au/), [Travel Massive](https://www.travelmassive.com/) and [Talentbookr](https://talentbookr.com.au/)) we realised that the `mix phx.new` generator it produces a very lean web application and leaves a lot of decision-making to the developer.
To the more experienced developer, this can be liberating, however, it's also great to have more of a turnkey solution with a sensible set of defaults that get you fully up and running. A solution that, out of the box provides:
- a component library so you don't have to think too much about the design
- working authentication and user management so users can register and change their settings right away
- admin functionality allowing the basic management of users
- a way of logging user activity so you can see how users use the application
- some email templates that are ready to go and easily editable
- a cheap and reliable email service provider chosen for you (but easily changeable) to send transactional emails
- a CRUD generator that produces a clean and deployable interface
- a way to deploy to production in less than 10 minutes
Having not found the above solution, me and my business partner Nic decided to build it - the result is Petal Pro.
ℹ️ Information:Not an Elixir developer?: Phoenix web apps now compete with Javascript single-page applications thanks to its impressive web socket abilities via LiveView. We hope more Javascript developers will see the immense time-saving abilities of using Phoenix (along with Petal Pro). Imagine having a web application that feels like a SPA, but is all server-side code. You still can create reusable components and don't need to worry about an API. It really can cut your development time in half.
## What's included in v4
v4 is the biggest release yet. Here's a summary of what's new on top of the existing foundation:
### GDPR compliance
A "Your Data" settings page (`/app/users/your-data`) lets users download all their personal data as a JSON file and submit account deletion requests. Deletions run as background jobs via Oban, with soft-delete and anonymization cascade across related records.
### AI admin chat (Jido-powered)
The admin chat interface is now powered by [Jido](https://hex.pm/packages/jido) with a clean tool behaviour pattern. Built-in tools cover user management, org management, changelog operations, and AI cost stats. Adding your own tools is straightforward. Write a `Jido.Action` module under `PetalPro.AI.AdminChat.Actions` and add it to `@actions` in `PetalPro.AI.AdminChat.ActionRegistry`. The admin chat and the MCP server both pick it up.
### Admin MCP server
Connect Claude Code or Claude Desktop directly to your running app. The MCP server at `POST /api/mcp` exposes admin tools via JSON-RPC 2.0 with bearer token auth. Set `MCP_ADMIN_TOKEN` and add the server to your `.mcp.json` — then your AI assistant can query users, manage orgs, publish changelog entries, and more without leaving your editor.
### Per-type notification preferences
Users can now control in-app and email delivery independently for each notification type. Security-critical notifications (like password change alerts) are forced-on and cannot be disabled. Use `Notifications.notify/3` as the single entry point — it handles preference checks automatically before dispatching.
### Rate limiting and error tracking
Auth endpoints are now protected by Hammer-based rate limiting out of the box. Sentry error monitoring auto-activates when you set the `SENTRY_DSN` environment variable — no code changes needed.
### Production Dockerfile
A production-ready Dockerfile is included for containerized deployments. No more rolling your own from scratch.
### Claude Code recipe commands
`.claude/commands/recipes/` ships with slash commands for common customizations: removing billing, switching auth methods, adding integrations, structural changes, and more. See the [recipes page](/petal-pro/recipes) for the full list.
---
# Changelog
# Source: https://petal.build/petal-pro/changelog
# Changelog
A history of changes to Petal Pro
### 4.5.2 - 2026-11-16
4.5.2 needs 4.5.1 underneath. On 4.5.0 or older, take 4.5.1 first, see the [upgrade guide](/petal-pro/upgrade-guide#4-5-1-4-5-2).
#### Security
- **Browser password sign-in is limited.** The sign-in form had no limit at all, so only the speed of the password check slowed a script working through passwords. An account now gets ten tries per ten minutes, counted before the password is checked, and a correct password counted on the account starts the count again. An email with no account is counted the same way, so a refusal doesn't show whether the account exists. A refused attempt goes back to the sign-in page with "Too many attempts. Please try again later." This has been the case since 4.0.0. See the [upgrade guide](/petal-pro/upgrade-guide#4-5-1-4-5-2).
- A count on an account could be turned against its owner, because anyone who knows an email could keep the count full. So a browser that has signed in to an account is counted on its own first, through a new cookie, `_petal_pro_web_sign_in_device` (encrypted, HttpOnly, one year). A stranger who uses up an account's count can then only block browsers that have never signed in to it. The cookie grants nothing else and stops counting when the account's password changes. A sign-in from a trusted browser leaves the account's count as it is, so other browsers stay refused until the window ends. List it in your cookie policy. A password reset also starts the account's count again. See [Trusted Browsers](/petal-pro/fundamentals/deployment#trusted-browsers).
- With `CLIENT_IP_HEADER` or `TRUSTED_PROXY_HOPS` set, one address also gets 100 failed tries per ten minutes across all accounts. Without either there is no limit per address, because every visitor would share it, and the app logs one warning when it sees proxy headers with neither set.
- Upgrade: take `lib/petal_pro_web/controllers/user_session_controller.ex` and `lib/petal_pro_web/live/auth/user_reset_password_live.ex`. Each runs without the other. The reset only starts the API count again with the new API `session_controller.ex` below. A test suite that posts more than ten wrong passwords for one account inside ten minutes now sees the refusal.
- **Limits that protect an account are counted on the account, not on the text typed.** The pin, API sign-in and password reset limits were keyed on the email as text. Postgres treats some spellings as the same email that `String.downcase/1` leaves different. Each such spelling found the same account and got a fresh count, so on common database setups the 4.5.1 pin limit could be multiplied. Every account limit is now keyed on the user id found by the same lookup the sign-in uses. The password reset limit was keyed on the raw text, so capitals alone got round it. See [Rate Limiting](/petal-pro/fundamentals/deployment#counted-on-the-account).
- Upgrade: take `lib/petal_pro_web/live/auth/passwordless_auth_live.ex`, `lib/petal_pro_api/controllers/session_controller.ex` and `lib/petal_pro_web/live/auth/user_forgot_password_live.ex`. Each works on its own. If you keep your own copy of one, key its limit on `user.id` after looking the user up, not on the email. Step 3 of the [upgrade guide](/petal-pro/upgrade-guide#4-5-1-4-5-2) shows the change for each.
- **An admin with a pending second factor could impersonate a user.** Signing in puts the user in the session before the two-factor step, and `POST /auth/impersonate` only checked for an admin. Impersonating and switching back gave a full admin session without the code ever being asked for, so an admin's password alone was enough. The controller now sends a pending sign-in to finish first. Impersonation is on by default.
- Upgrade: take `lib/petal_pro_web/controllers/user_impersonation_controller.ex`. If you have routes of your own behind `:require_admin_user` without `:authenticated`, add `:authenticated` to them: they have the same hole.
- **Confirmation emails can't be resent without limit.** The resend form and `POST /api/send-instructions` had no limit, so anyone could send confirmation emails to an unconfirmed account's address over and over. Both now share three per ten minutes for an account. The API answers a refusal with a 429.
- Upgrade: take `lib/petal_pro_web/live/auth/user_confirmation_instructions_live.ex` and `lib/petal_pro_api/controllers/registration_controller.ex`.
#### Changed
- **Per-address limits count an IPv6 client by its /64.** One subscriber usually holds a whole /64, so counting each address gave them a fresh budget on every request. Clients that arrive as IPv4-mapped or NAT64 addresses are counted as the IPv4 address they carry. `ClientIp.get/2` is unchanged, so `last_signed_in_ip` and the audit log still record the full address. Take `lib/petal_pro_web/client_ip.ex`.
- **The passkey sign-in limit only applies when the client address is configured.** Behind a proxy with neither setting made it was one count for the whole app, which a single caller could hold shut for everyone. A passkey can't be guessed, so nothing is lost. Take `lib/petal_pro_web/controllers/user_passkey_controller.ex`, and `test/petal_pro_web/controllers/user_passkey_controller_test.exs` with it: the 4.5.1 "eleventh attempt" test fails against the new controller.
- **A malformed sign-in form post is an ordinary failure.** A body with no email or password, or with a list where text should be, used to be a 500.
### 4.5.1 - 2026-11-14
#### Security
- **A passwordless sign-in pin could be guessed without limit.** Asking for a pin was limited to three per ten minutes, but "Resend" was not: it issued a new pin with a fresh set of attempts every time it was called, so a script could alternate three guesses and a resend indefinitely. The same email in different capitals also got a limit each. Resend now goes through the same limit as the first request, and the limit is per account whatever the capitals. Guesses sent in parallel could also all pass the attempts check before any of them was counted; each guess now takes its attempt in one database statement before the pin is compared. With the fix an account gets nine guesses per ten-minute window on each machine, and up to twice that for a caller who straddles the end of a window. This has been the case since passwordless sign-in shipped. 4.5.2 closes a way round that limit: on some databases the same account could be reached under another spelling of its email, each with a count of its own, and on 4.5.2 the count is kept on the account. See the [upgrade guide](/petal-pro/upgrade-guide).
- Upgrade: take `lib/petal_pro/accounts/user_pin.ex` and `lib/petal_pro_web/live/auth/passwordless_auth_live.ex` together. `UserPin.check_pin/3` replaces `validate_pin/3` followed by `failed_attempt/1`. Both old functions still work and are deprecated: `validate_pin/3` now counts the attempt itself and `failed_attempt/1` does nothing, so a LiveView you customised keeps its three guesses per pin and gets two deprecation warnings until you switch, which fail `mix compile --warnings-as-errors`. That is a stopgap, not the fix: the unlimited resend is in the LiveView. If you keep your own, make the six changes in step 3 of the [upgrade guide](/petal-pro/upgrade-guide): the main ones route its `resend` handler through `send_pin/2`, so a resend meets the same limit as the first request, and lower-case the email in the limit key. Until then "Resend" still issues pins without limit in your app. Take `test/petal_pro/user_pin_test.exs` with the new `user_pin.ex` too, because the 4.5.0 copy has a test that fails against it.
- **Two-factor codes are limited to five tries per five minutes.** The TOTP step had no limit, so someone who already had a user's password could work through six-digit codes until one matched. The limit is per user, counts every submit and needs no configuration. A correct code starts the count again, and a user who mistypes five times in a row waits out the window. Backup codes go through the same form and the same limit.
- **API sign-in is limited per account as well as per address.** Ten tries per ten minutes for one email, whatever addresses they come from. A sign-in that works starts the count again, so a client that signs in often is not refused for its own successes. The per-address limit alone does nothing against a caller with many addresses (an IPv6 range, a botnet), who meets a fresh budget each time. 4.5.2 closes a way round this limit: on some databases the same account could be reached under another spelling of its email, each with a count of its own, and on 4.5.2 the count is kept on the account.
#### Fixed
- **The API and passkey rate limits count the client, not the proxy.** The API sign-in (5 a minute), API registration (3 an hour) and passkey sign-in (10 a minute) limits were keyed on `conn.remote_ip`. Behind Fly, Render, nginx or any other proxy that is the proxy's address, so every visitor shared one budget: three API registrations an hour for the whole app, and one caller could use any of the three up for everyone. They now use the address `PetalProWeb.ClientIp` resolves, the one `last_signed_in_ip` has recorded since 4.5.0, through the new `PetalProWeb.ClientIp.rate_limit_key/2`. This has been the case since the limits were added (4.0.0 for the API, 4.1.0 for passkeys). See the [upgrade guide](/petal-pro/upgrade-guide).
- Upgrade: this only takes effect once the app knows which address is the client's. If you have not set `CLIENT_IP_HEADER` or `TRUSTED_PROXY_HOPS`, nothing changes and visitors behind your proxy still share a budget. On Fly, add `CLIENT_IP_HEADER = "fly-client-ip"` to the `[env]` block of `fly.toml` (the same step as in the 4.5.0 notes). Behind Cloudflare use `cf-connecting-ip`; behind one nginx or Caddy use `TRUSTED_PROXY_HOPS=1`. See "Client IP Behind a Proxy" in `DEPLOYMENT.md`.
- Upgrade: if you copied one of these `rate_limit` plugs, swap its `conn.remote_ip` line for `PetalProWeb.ClientIp.rate_limit_key(conn, "")`.
- **The passkey rate limit no longer counts page views, and it answers when it refuses.** The sign-in page asks for a passkey challenge every time it loads, and each one counted against the same ten a minute as real sign-in attempts, so ordinary traffic could use the budget up. Past the limit the request was stopped without a response, which is a 500. Only sign-in attempts count now, and a refused one goes back to the sign-in page with "Too many attempts".
### 4.5.0 - 2026-11-11
#### Security
- **`UserAuth.get_ip/1` no longer trusts the client-written `x-forwarded-for`.** It used to take the first `x-forwarded-for` entry, which the client controls. The new `PetalProWeb.ClientIp` returns the connection peer unless config names a trusted proxy. The chosen value is parsed strictly, and anything malformed falls back to the peer. `last_signed_in_ip` and impersonation audit entries now record a real address, and an `x-forwarded-for` entry over 255 characters, or one that isn't valid UTF-8, can no longer 500 a sign-in after the session token was minted. See the [upgrade guide](/petal-pro/upgrade-guide).
- Upgrade: on Fly, add `CLIENT_IP_HEADER = "fly-client-ip"` to the `[env]` block in `fly.toml`, or sign-ins will record Fly's proxy address.
- Upgrade: elsewhere, set `CLIENT_IP_HEADER` to your proxy's header (e.g. `cf-connecting-ip`) or set `TRUSTED_PROXY_HOPS` (how many trailing `x-forwarded-for` entries your proxies append, default `0`). `TRUSTED_PROXY_HOPS=2` also works on Fly, and `1` works behind a single nginx. It must be a whole number, or the release fails to boot.
- Behaviour change: for a peer that isn't an IP, `get_ip/1` now returns `nil` where it used to raise.
- **Production forces HTTPS.** The new `PetalProWeb.ForceSSLPlug` wraps `Plug.SSL` with runtime config from `config/runtime.exs` (validated once at boot from `PetalPro.Application`). In prod it trusts `x-forwarded-proto` and `fly-forwarded-proto` (`rewrite_on`), redirects plain http (301 for GET and HEAD, 307 for other methods) and sends a one-year HSTS header on https responses. Because a proxied https request now counts as https, Plug marks the cookies it writes, including the session and remember-me cookies, `Secure`. HSTS itself sets no cookie flags. The session cookie options also set `same_site: "Lax"` and `http_only: true` outright. Behind Fly, Render, Railway and similar hosts, cookies no longer go out without `Secure`, and Firefox and Safari now treat the session cookie as Lax instead of sending it on every cross-site request. See the HTTPS section in `DEPLOYMENT.md`.
- Upgrade: the new `FORCE_SSL` env var is on by default in prod (on when unset, `true` or `1`, off for any other value). Behind a proxy that sends no forwarded-proto header, every request redirects to itself unless you set `FORCE_SSL=false`. Keep it on if you terminate TLS in the app.
- Upgrade: an HTTP health check (for example one in `fly.toml`) needs an `X-Forwarded-Proto: https` header or a path exclusion in `config :petal_pro, :force_ssl` of the form `exclude: [hosts: ["localhost", "127.0.0.1"], paths: ["/healthz"]]` (keep the `hosts` entry, since any `exclude` replaces Plug.SSL's default), or it gets a 301. Default TCP checks are unaffected.
- **Sentry request context.** The new `PetalProWeb.SentryContextPlug` adds request context to Sentry events, using the same client IP as `PetalProWeb.ClientIp`. It masks sign-in secrets: the TOTP code, PIN, `sign_in_token`, passkey assertions, OAuth code and state, and confirm and reset tokens. It does nothing until `SENTRY_DSN` is set. If you care about what you send to Sentry, note that events now include request context, including the client IP.
#### Changed
- **Settings screens move to a two-pane layout.** At `lg` and up the settings nav sits in its own pane, with a pill and primary-coloured text and icon on the active item, `aria-current` on the active link and a real nav landmark. The content card has new chrome. Below `lg` the nav becomes a horizontal scroll strip with edge fades, and the new `ScrollStripHook` keeps the active item centred. This covers every user, org and billing settings screen, and none of them need code changes on your side. `page_header/1` and `box/1` are unchanged. See the [upgrade guide](/petal-pro/upgrade-guide).
- Upgrade: if you customised `sidebar_tabs_container/1` or `sidebar_menu_item/1` in `page_components.ex`, merge those by hand.
- New pieces: `assets/js/hooks/scroll-strip-hook.js` (registered as `ScrollStripHook` in `hooks/index.js`), and `scrollbar-none` and `scroll-strip-fade` `@utility` blocks in `app.css`.
- **Every settings screen gets a header and its own page title.** Each screen now opens with the new `settings_header/1`, which has a one-line description, and sets its own `page_title`, so browser tabs read "Email - Petal" or "Password - Petal" where stock used to show a literal "Settings" (profile, Your Data) or just the app name. Nav labels are now nouns: "Edit profile" becomes "Profile", "Change email" becomes "Email", "Edit password" becomes "Password", "Edit notifications" becomes "Notifications" and the org "Edit" becomes "General". This only changes copy, but tests that assert the old labels or headings need updating. Every string goes through gettext, so translations need the new msgids.
- **Settings forms share one layout.** Single text, email and password fields are capped at `max-w-md`, so the profile, email, password and org forms no longer stretch inputs to about 900px. Every editable form ends in a `border-t` action bar with the primary button on the right. The password form keeps "Forgot your password?" on the left. Only classes and markup changed. Handlers, params and validations are untouched.
- **The billing screen is rebuilt around a plan card.** The card shows the product, a Trial badge, the price, and a `dl` with the last invoice, the upcoming invoice and the next charge. Cancelling now goes through a destructive `alert_dialog` ("Keep my subscription" / "Cancel anyway") that shows plan, price and next charge before you confirm. It replaces the dropdown and the browser `data-confirm`. With no subscription you get an `<.empty>` state with a single View plans button, and a provider failure shows a danger `<.alert>`. Event names, routes and params are unchanged, and `cancel_subscription` still drives the cancel. Tests that relied on `data-confirm` or the old spinner markup need updating.
- **Account deletion on Your Data becomes a danger-zone panel.** The panel has a danger hairline, a warning icon chip and a list of consequences. The inline two-stage confirm is replaced by a destructive `alert_dialog` ("Delete my account" / "Keep my account"), and status notices are now `<.alert>`s. The GDPR flow and `confirm_delete` are unchanged. The `show_delete_confirm` and `cancel_delete` events that drove the old inline confirm are removed, so any code or tests that send them will break. Org deletion still has no UI, by design.
- **Notification preferences are switches.** Each preference renders as `<.field type="switch">` in place of a checkbox, and still sends the same `toggle_preference` event and payload. Channels locked by `allow_disable_in_app` / `allow_disable_email` show as disabled, always-on switches. Tests that select checkbox inputs may need updating.
- **TOTP setup is clearer.** Setup is two numbered step cards (a framed QR code or a select-all mono secret), and the code field is now petal_components' `input_otp` (6 segments, `autocomplete="one-time-code"`), so SMS and password-manager autofill work. It still posts `user_totp[code]`. Once 2FA is on, the screen shows a `success-*` status row, and backup codes are select-all mono chips. Disabling 2FA and regenerating backup codes move from `data-confirm` to destructive `alert_dialog`s. Form params are unchanged. Tests that assert "2FA Enabled" (now "2FA enabled") or `data-confirm` selectors need updating. The `input_otp` wrapper takes the `id`, and the real input is `id <> "-input"` (`totp-code-input` in stock Pro).
- **The passkeys screen matches the rest of settings.** Its six inner panels move to the gray-400 alpha ladder and `--pc-radius`. This also fixes two dark-mode contrast problems: the gray-800 key-icon circle and the gray-800/50 info wash. Only classes changed.
- **The last three hand-rolled modals now use `<.modal>` from petal_components.** The onboarding LiveView and both email-link unsubscribe pages now render petal_components' `<.modal hide_header>` in place of their own hand-rolled modal markup, and pick up the library's dark mode and focus handling. If you customised the onboarding or unsubscribe templates, re-port them onto `<.modal hide_header>`.
- **Flash messages are toasts.** `PetalProWeb.Flash.flash_group/1` renders petal_components' `<.toast_group>` with its `put_flash` bridge, so every `put_flash(:info | :success | :warning | :error)` shows as a stacked, swipe-to-dismiss toast with a progress bar. Call sites don't change. The 10 second timer stays, and a new `position` attr sets where toasts appear. LiveViews can call `PetalComponents.Toast.send_toast/3` for richer toasts. Only those four flash kinds reach the toast, so app-private flash keys stay out. The disconnected banner is unchanged. It can overlap a toast bottom-right, so use `position="bottom-left"` if that bothers you.
- **Empty states use `<.empty>`.** Every hand-rolled empty state now has a title, a one-sentence description and a single CTA where a create action exists. Covered: the DataTable fallback on all admin indexes (with "Clear filters" when filtered), the notifications page and bell, admin chat history, admin user and org show memberships, the orgs list, org team invitations, passkeys, org invitations, the blog index, the admin dashboard chart panels, and the admin file picker, which had no empty state before. DataTable keeps `empty_icon` / `empty_title` / `empty_description`. The titles keep their wording, so tests that match the copy still pass. Tests that select the old empty-state markup (a bare `
`, a dashed box, an icon circle) need updating to the `.pc-empty` structure.
- **Status pills use `<.status_badge>` and roles use `<.role_badge>`.** `<.status_badge status={@status}>` is a `<.badge dot>` rendered through the new `PetalProWeb.StatusBadge` (imported by `use PetalProComponents`). One status-to-colour map now covers subscriptions, the billing card, changelog draft/published/archived, user state, dashboard recently-joined and invitation state. Admin user show gains a Status row, the org team table gains a Status column, and every row in Admin > Users carries a role chip.
- Removed helpers: `ChangelogHelpers.status_badge_class/1` is gone, so call `<.status_badge>` in its place. The private `role_label` / `role_badge_color` helpers in `OrgsLive` and `AdminOrgLive.Show` are gone too.
- Colour changes: trialing on the admin subscriptions table and the admin role both go from warning to info. On the dashboard, unconfirmed becomes a warning chip and not-onboarded a gray chip (both were a red X). To restore the old colours, edit `status_color/1` or `role_color/1` in `PetalProWeb.StatusBadge`.
- **petal_components 4.6.0 to 4.18.0.** The minimum is now `~> 4.18`, and phoenix 1.8.16, phoenix_html 4.4.0 and phoenix_pubsub 2.4.1 come along. The update also moves Pro's production web server, bandit 1.12 to 1.14 and thousand_island 1.5 to 1.6, plus smaller bumps to lazy_html, plug_crypto, elixir_make and fine. See the [upgrade guide](/petal-pro/upgrade-guide).
- Upgrade: run `mix deps.update petal_components` after taking this release.
- Upgrade: `Layouts.empty/1` is renamed to `Layouts.blank/1`, because the library now ships `<.empty>`, so calls to `Layouts.empty` break.
- Upgrade: the library now exports names Pro used to define (`combo_box` from 4.12, `data_table` from 4.13, plus the four components under Removed). `PetalProComponents` imports the free modules, drops the Pro copies it deletes, and keeps Pro's own `data_table` with `import PetalComponents.DataTable, except: [data_table: 1]`. If you edited that file, match the 4.5.0 import list in the upgrade guide or the build fails with "call is ambiguous".
- What you pick up along the way:
- 4.6.1/4.6.2: dark and ghost surfaces follow the remapped gray, so sign-in inputs and dropdown triggers match Pro's slate panels.
- 4.11: `hide_header` on `<.modal>`.
- 4.12: free `combo_box`.
- 4.13: free `data_table`.
- 4.15: `<.empty>`, a `:footer` slot on modal, and dropdown auto-flip (a dropdown panel opens upward when there's no room below).
- 4.16: Typeset font tokens (`--pc-font-heading`,
`--pc-font-body`,
`--pc-font-mono`), so one `@theme` block can retype the whole UI, plus lining numerals on counters, a single error ring on `input_group`, and a `slide_over` that falls back instead of crashing on an unknown origin.
- 4.16.1: `shrink-0` on the colour-scheme switch and icon triggers.
- 4.17.1: multi-select `combo_box` posts values in pick order.
- 4.18.0: the toast hook no longer logs a console error on controller-rendered pages, and `<.alert>` gains `dismiss_label`.
- New components such as empty, slider, filters, kbd and qr_code are available.
- **Flop 0.26.3 to 0.27.0.** This supports the new DataTable FlopBridge (below). Pro's two settings modules were updated for it.
- Upgrade: `mix.exs` still allows `~> 0.20`, so the bump comes from `mix.lock`. Flop 0.27.0 requires `:ecto_type` on every join field and custom field, so your own `Flop.Schema` derivations with `join_fields` or `custom_fields` fail until they're annotated.
- Behaviour change: 0.27 caps filters per request at 20 by default (`max_filters`).
#### Removed
- **Four Pro components retire in favour of their petal_components versions.** `color_scheme_switch`, `language_select`, `local_time` and `social_button` are now provided by the free library, so the Pro copies are deleted. `PetalProComponents` imports the free modules, so `use PetalProComponents` still provides every name. The `ColorSchemeHook` and `LocalTimeHook` JS hooks are deleted. See the [upgrade guide](/petal-pro/upgrade-guide).
- Upgrade: delete the four old files in `lib/petal_pro_web/components/pro_components/` (`color_scheme_switch.ex`, `language_select.ex`, `local_time.ex`, `social_button.ex`), and `assets/js/hooks/color-scheme-hook.js` and `local-time-hook.js` along with their `index.js` entries. Fully qualified calls such as `PetalProWeb.ColorSchemeSwitch.color_scheme_switch` break, so use the plain tags.
- `color_scheme_switch`: now requires an `id`. `` in the head becomes `<.color_scheme_script />`. It uses the same `localStorage.scheme` key, so saved preferences survive, and it adds live system-preference tracking and cross-tab sync.
- `local_time`: now requires an `id`. `for=` becomes `at=`. luxon `preset=` names and `format=` token strings are replaced by `format="datetime"` (the default, roughly the old `DATETIME_MED`), `"date"`, `"time"`, `"relative"` or a map of `Intl.DateTimeFormat` options. `locale` now defaults to the browser's own, where it used to default to `"en"`. luxon is now orphaned in `package.json` and can be dropped.
- `social_button`: `logo=` becomes `provider=` and `link_type="a" to=` becomes `href=` (`navigate=` and `patch=` cover the live link types). The twitter bird is now `x`. `variant` now defaults to `"outline"`, where it used to default to `"solid"`.
- `language_select`: a straight swap.
- If you have a customised fork of the old Pro copies, keep it and skip this part.
- **Tom Select.** `PetalProWeb.ComboBox`, the `ComboBoxHook`, `assets/css/combo-box.css` (about 12 KB) and the `tom-select` npm package are deleted. The two admin membership pickers and the `petal.gen.live` / `petal.gen.html` generators now render `<.field type="combobox">` from petal_components, which carries its value in a hidden native select. Selections now survive a LiveSocket reconnect through LiveView's own form recovery (customer issue #306). A new `tom_select_retired_test.exs` fails if any remnant is left. See the [upgrade guide](/petal-pro/upgrade-guide).
- Upgrade: `<.combo_box label= help_text= />` becomes `<.field type="combobox" label= help_text= />`. `tom_select_plugins` (its `remove_button` plugin) becomes `clearable`, which is off by default where the old remove button was on, and `remove_button_title` becomes `remove_label`. `multiple`, `create`, `max_items`, `placeholder`, `disabled`, `required`, `remote_options_event_name` and `remote_options_target` keep their names. `tom_select_options` and `tom_select_options_global_variable` have no equivalent.
- Behaviour change: a disabled single-select combobox posts nothing for its field, because there is no longer a hidden `""` input.
- Cleanup: delete `assets/js/hooks/combo-box-hook.js` and its `ComboBoxHook` line in `hooks/index.js`, `assets/css/combo-box.css` and its `@import` in `app.css`, and `lib/petal_pro_web/components/pro_components/combo_box.ex` with its `import PetalProWeb.ComboBox` in `PetalProComponents` (replaced by `import PetalComponents.ComboBox`). Then run `npm uninstall tom-select --prefix assets`.
- If you have a forked wrapper, keep it and skip this part.
#### Added
- **Layout shell options.** `sidebar_layout` gains a `mobile_top_right` slot. Menu items take `related_pages`, matched by one shared function, `PetalProWeb.SidebarMenu.menu_item_active?/2`, and the active link carries `aria-current`. In stock config `:subscribe` relates `:subscribed` and `:billing`, so Subscribe stays highlighted on billing pages. `sidebar_user_profile` gains a `top_nav` variant and an `id` attr, so the user menu can live in a top bar.
- Upgrade: matching is explicit (no prefix match), so add `related_pages` for any nested page that should light up an item.
- Upgrade: the colour-scheme switches now have fixed ids (in 4.4.0 each render got a random UUID): `sidebar-user-profile-color-scheme` in the sidebar user dropdown (prefixed by the new `id` attr, default `sidebar-user-profile`), `navbar-color-scheme` / `navbar-color-scheme-mobile` in the stacked layout and `public-navbar-color-scheme` on public pages.
- **DataTable FlopBridge.** `PetalPro.DataTable.FlopBridge` connects Flop queries to petal_components' free `data_table`, and a differential test gate checks 986 cases against the library's in-memory engine. No admin screen uses it yet, so nothing visible changes. It lays the groundwork for moving admin screens to the free `data_table` later.
- **A third collision-guard test.** It compiles the real `use PetalProWeb, :html` import scope to catch name clashes between Pro and petal_components.
- **Generator CI job.** Every `petal.gen.*` generator runs on every push and its output has to compile, so generator drift shows up in CI.
#### Fixed
- **The billing screen no longer crashes at a month boundary.** The meter summary guards compared `DateTime` structs with `>`, which compares them structurally, so a valid Aug 31 to Sep 1 window failed with `FunctionClauseError`. That hit metered subscriptions in the first days of any month whose billing period started the month before. The check now uses `DateTime.compare/2` (or an integer compare for Unix timestamps). An inverted range now raises a clear `ArgumentError`.
- **The failed billing state no longer shows "No active subscriptions" under the error.** A provider failure now renders only the danger `<.alert>`.
- **Semantic colour utilities always render their real colour.** The semantic aliases in `colors.css` (`danger`, `success` and the rest) used `@theme inline`. Tailwind v4 tree-shakes each stop separately, so a semantic stop went unresolved unless the matching literal palette stop happened to be used somewhere, and utilities like `text-danger-400` silently fell back to inherited gray. The alias block now uses plain `@theme`. If you edited `assets/css/colors.css`, make the same one-line change on your alias block.
- **The unsubscribe pages are clickable again.** Under Tailwind v4 the gray overlay on both email-link unsubscribe pages painted over the confirmation panel and blocked clicks. The move to `<.modal>` (above) replaces that hand-rolled markup.
- **Sidebar menu items with the same label no longer produce duplicate HTML ids.** Ids now derive from `:name`, falling back to a slug of the label. This applies to `menu_item__anchor` and `dropdown_` / `dropdown__button`. It fixes invalid markup and broken id-based test selectors when menus reuse a label, such as "Settings" in both the org and user groups (customer issue #298). Stock ids change wherever a name differs from its label: `menu_item_organizations_anchor` is now `menu_item_orgs_anchor`, and in the admin sidebar `menu_item_users_anchor` is now `menu_item_admin_users_anchor` and `menu_item_live_dashboard_anchor` is now `menu_item_server_anchor`. Custom JS, CSS or tests that target the old label-derived ids need updating.
- **Combo box selections survive a LiveSocket reconnect** (customer issue #306). See the Tom Select removal above.
- **Mobile layouts clear the iOS browser bar.** `sidebar_layout` and `stacked_layout` use `h-dvh` in place of `h-screen`, so the sidebar's profile row and the last line of a page no longer sit under the browser bar. `<.layout type="stacked">` also renders the caller's `top_right` / `top_right_mobile` slots, which it used to drop.
- **`mix quality` passes end to end on a fresh clone again.** A too-deep function in the passkey settings LiveView is flattened for `credo --strict`. The S3 module now signs download and delete requests with the full SigV4 config, which clears 11 dialyzer warnings with no new ignore entries.
- **Flash messages on controller-rendered pages no longer log a console error.** A flash on a page rendered by a controller, not a LiveView, used to log "unable to push hook event. LiveView not connected" in the browser console, because the toast hook tried to talk to a LiveView that wasn't there. Fixed upstream in petal_components 4.18.0, which this release requires.
- **The Stripe logo on the landing page draws in full.** A doubled minus sign in its SVG path data stopped the browser parsing partway through, so the "p" lost its counter, the "e" never drew and every visit logged an SVG path error in the console.
---
### 4.4.0 - 2026-07-17
#### Changed
- **Adopted petal_components v4.6.** `aurora` and `border_beam` used to be Petal Pro components. They are now part of the free petal_components library, rebuilt with glow, multiple beams, and spring easing, so Pro deletes its own copies and consumes the free ones like every other component. The dependency minimum is now `~> 4.6`. Take Pro 4.4.0 *before* you run `mix deps.update petal_components`: bump petal_components first on an older Pro and the build fails with `function border_beam/1 imported from both PetalProWeb.BorderBeam and PetalComponents.BorderBeam, call is ambiguous`, because both libraries now export it. `aurora` is the same problem but quieter, since Pro never calls it itself. If you customised either component a handful of attributes were renamed. See the [upgrade guide](/petal-pro/upgrade-guide) for the rename tables and, if your membership has lapsed, a complete manual fix that needs no repo access.
- **Ported the sign-in card to the free `border_beam`.** `auth_layout` now uses the free component (`gradient_color_start` becomes `color_from`, `gradient_color_end` becomes `color_to`, `animation_duration` becomes `duration`). The free beam styles its own panel, so the card's background, border and radius classes came out, and the corner radius now follows your `--pc-radius` theme token. Dark mode picks up the library's material in place of the old translucent blur.
#### Removed
- **`floating_div` and its `@floating-ui/dom` npm dependency.** It had no call sites left in Pro. Reach for the free `popover` in top-layer mode (`<.popover top_layer>`) instead, which covers the same case of a panel escaping a clipped container. A `<.floating_div>` in your own code raises a compile error on upgrade; the [upgrade guide](/petal-pro/upgrade-guide) has the swap.
#### Added
- **Reserved-namespace guard test.** `test/petal_pro_web/components/petal_components_collision_test.exs` walks both libraries at runtime and fails if any Pro component defines a name that `use PetalComponents` also exports. This is what stops the ambiguous-import bug from ever coming back, and it drops straight into your own test suite.
- **Excluded the petal_components showcase from the Tailwind scan.** `assets/css/app.css` gains a `@source not` line for the dependency's showcase example modules, so their markup stops pulling extra classes into your CSS build.
---
### 4.3.0 - 2026-06-24
#### Added
- **Private S3 buckets.** Set `private: true` in your `:s3` config and uploads stay out of public view. `consume_uploaded_entries/2` stores just the object key, and `PetalPro.FileUploads.download_url/1` returns a short-lived presigned GET URL when you display the file. It is a no-op for public buckets and other providers, so you can call it unconditionally in your templates.
- **Cloudflare R2 and Fly Tigris support.** Point the new `endpoint` config at R2, Tigris, or any S3-compatible service and uploads, downloads, and deletes all run through the same presigned path. Both ride on the existing S3 provider.
- **File deletion across providers.** Every upload provider now implements `delete_file/1`, and a user's old avatar is removed from storage automatically when they replace or clear it.
- **SAML SSO recipe.** A new `/recipes:add-saml-sso` walkthrough for wiring up enterprise identity providers (Okta, Microsoft Entra, Google Workspace), with the security prerequisites spelled out.
---
### 4.2.0 - 2026-06-08
#### Changed
- **Upgraded to Petal Components v4.** Petal Components dropped Alpine.js (every component is now `Phoenix.LiveView.JS` only) and ships its own JS. `assets/js/app.js` now imports the `petal_components` bundle and merges its hooks into the LiveSocket - these power the password / copyable / clearable inputs, the accordion, and the Chat components. Alpine.js stays for Petal Pro's own components (sidebar persistence etc.), so nothing else changes for you. The `js_lib` attribute was removed from `<.dropdown>`, `<.accordion>`, and the menu components and now raises if passed - if you've customised a call site that passes `js_lib`, drop it. See the [Petal Components v4 upgrade guide](https://hexdocs.pm/petal_components/upgrade_guide.html).
---
### 4.1.0 - 2026-05-21
#### Added
- **WebAuthn passkey authentication** - register up to 5 passkeys (Face ID, Touch ID, hardware keys) from your security settings. Two modes: primary auth (passwordless sign-in) and second factor (2FA on top of password). Includes cloned authenticator detection via sign count validation and a guard against passkey 2FA bypass in `require_authenticated_user/2`
- **Persistent admin chat history** - AI admin chat conversations are now stored in the DB. They survive reloads and restarts, and the sidebar lists recent conversations so you can pick up where you left off
- **`mix quality` now runs `credo --strict` and `dialyzer`** - fresh clones pass both out of the box. Existing projects will need to clean up any strict credo violations and get dialyzer running
#### Fixed
- Passkey sign-in session establishment before redirect
- Cloned authenticator detection via sign count validation
- Passkey 2FA bypass guard in `require_authenticated_user/2`
---
### 4.0.0 - 2026-05-04
#### Added
- **GDPR compliance** — "Your Data" settings page (`/app/users/your-data`) lets users download all personal data as JSON and submit account deletion requests with soft-delete, anonymization cascade, and Oban background processing
- **Per-type notification preferences** — users can toggle in-app and email channels independently per notification type; security-critical notifications (e.g. password changes) are forced-on and cannot be disabled
- **`Notifications.notify/3` entry point** — single dispatch function that checks per-user, per-type preferences before sending in-app or email notifications
- **Welcome notification** on registration and password change alert on password update
- **Admin MCP server** — exposes admin tools to external AI clients (Claude Code, Claude Desktop) via JSON-RPC 2.0 at `POST /api/mcp` with bearer token auth; set `MCP_ADMIN_TOKEN` env var
- **AI cost tracking** — Req plugin that automatically logs every AI API call with token counts, costs, and timing to the `ai_call_logs` table
- **Admin chat tools** — `ManageUser` (suspend/unsuspend/delete/restore/promote), `ListOrgs`, `ManageOrg` (rename/delete/members), and `GetAiCallStats`
- **Changelog MCP tools** — `list_changelog_updates`, `manage_changelog`, and `create_changelog_update` for AI admin chat and external MCP clients
- **In-app feedback system** — users can submit feedback from any page; admin dashboard for reviewing and managing submissions
- **Sentry error monitoring** — auto-activates when `SENTRY_DSN` env var is set; no code changes required
- **Hammer-based rate limiting** — applied to auth endpoints via plugs
- **Resend email adapter** — set `RESEND_API_KEY` to use Resend for transactional email via Swoosh
- **Production Dockerfile** — ready-to-use containerized deployment
- **Generic JS hooks collection** — infinite scroll, scroll to bottom, scroll to hash, select all, share
- **Email component enhancements** — configurable gap, gray button variant, and callout boxes
- **Dev scripts** — `server.sh`, `reset_db.sh`, `kill_db.sh` for common development tasks
- **Lightweight page view analytics** — bot filtering and daily aggregation
- **Daily Slack digest worker** — activity summaries via Oban cron
- **Slow query telemetry logging** — configurable threshold for dev environment
- **Interactive DB schema visualizer** — dev page with Mermaid ER diagrams (pan/zoom), domain-grouped tables, column details with PK/FK indicators
- **Hierarchical route tree** — collapsible tree view mirroring URL path structure with verb badges and click-to-copy helpers
- **22 AI-powered recipe commands** (`.claude/commands/recipes/`) — Claude Code slash commands for common customizations: auth, billing, feature removal, integrations, structural changes
- **Claude Code sub-agents** — `schema-architect`, `test-runner`, `elixir-reviewer`, `heex-reviewer`, `ui-ux-reviewer`
- **Claude Code skills and commands** — CI, commit, review, changelog, scaffolding workflows
- **COMPONENTS.md** — reference document cataloging all available components and JS hooks
- **CLAUDE.md project instructions** — scoped per directory for in-repo AI context
#### Updated
- **Jido AI for admin chat** — replaced LangChain with native `Jido.Action` modules under `PetalPro.AI.AdminChat.Actions.*`, registered in `ActionRegistry` and shared by both the chat LiveView and the MCP server
- **Req for all HTTP calls** — replaced HTTPoison and Tesla throughout
- **Sidebar-only layout** — converted to sidebar-only; no desktop header; integrated user profile and notification badge
- **Styler upgraded from 0.11 to 1.11** — run `mix format` after upgrading
- **Changelog context** — restructured `ChangelogUpdates` → `Changelog` with proper schema naming (`Update`, `Like`, `Read`), Flop DataTable with pagination/sorting/filtering on admin index, shared `ChangelogHelpers` module, comprehensive test coverage, and SEO meta descriptions on public pages
- **Modularized seed system** — split into production and development modules
- **Fly.io deploy** — now triggers on push to main
- **NPM packages updated** — including ESbuild, with updated `esbuild.js`
- **Sidebar collapse button** — redesigned as flush edge tab with directional chevrons; deferred transitions prevent flash on load
- **Updated deps** — `phoenix_live_view 1.1.27`, `petal_components 3.0.2`, `jido 2.1`, `sentry 12.0.3`, `swoosh 1.23.1`
#### Fixed
- Wallaby test race condition in signup flow
---
### 3.0.0 - 2025-07-22
- Upgrades Petal Pro to Tailwind 4!
- New Pro components - Aurora and BorderBeam
- Adds support for Stripe metered usage
- Replaces Admin Jobs with Oban Web
- Adds `TailwindFormatter`
- Port is configurable for the test environment
- Updated: Adds `mix assets.build`
- Updated: Combobox will warn if `:tom_select_options_global_variable` includes load handler and `:remote_options_event_name` is set
- Fixed: SubscribeController redirects and shows Stripe error
- Fixed: Authenticated views no longer auto-subscribe to user notifications
- Fixed: Adds missed exception for blog route
- Fixed: Seeder clears posts/files properly
- Fixed: Post/File is based on PetalPro.Schema
- Fixed: Combobox does not disappear when navigating to another page
#### Upgrade Notes
Petal Pro has been upgraded to Tailwind 4. Some utilities have been removed or renamed. See the [Tailwind upgrade guide](https://tailwindcss.com/docs/upgrade-guide) for more information.
To upgrade to Tailwind 4 in your project, make sure you update `mix.exs`:
```diff
- {:tailwind, "~> 0.2", runtime: Mix.env() == :dev}
+ {:tailwind, "~> 0.3", runtime: Mix.env() == :dev}
```
And `config.exs` (note that the paths have changed and that you need 4.0.9 or above):
```diff
config :tailwind,
- version: "3.3.3",
+ version: "4.1.11",
default: [
args: ~w(
- --config=tailwind.config.js
- --input=css/app.css
- --output=../priv/static/assets/app.css
+ --input=assets/css/app.css
+ --output=priv/static/assets/app.css
),
- cd: Path.expand("../assets", __DIR__)
+ cd: Path.expand("..", __DIR__)
]
```
Don't forget to run:
```shell
mix tailwind.install
```
#### Updated app.css
`app.css` has been updated to support CSS first configuration:
app.css
```elixir
@import "tailwindcss";
@source "../../deps/petal_components/**/*.*ex";
@import "../../deps/petal_components/assets/default.css";
@import "./colors.css";
@import "./combo-box.css";
@import "./editorjs.css";
@import "./animations.css";
@import "../node_modules/tippy.js/dist/tippy.css" layer(components);
@plugin "@tailwindcss/typography";
@plugin "@tailwindcss/forms";
@plugin "@tailwindcss/aspect-ratio";
@plugin "./tailwind_heroicons.js";
...
```
To see the latest changes for 3.0.0, go to:
[https://github.com/petalframework/petal_pro/tree/v3.0.0/assets/cssgithub.com](https://github.com/petalframework/petal_pro/tree/v3.0.0/assets/css)
The following files have changed:
- `app.css`
- `combo-box.css`
- `editorjs.css`
The following files have been added:
- `colors.css`
- `animations.css`
- `tailwind_heroicons.js`
Finally, `tailwind.config.js` has been removed.
Now you should be able to follow the [Tailwind upgrade guide](https://tailwindcss.com/docs/upgrade-guide) to update the rest of your project. Running `mix format` should automatically arrange tailwind classes in your project.
### 2.2.0 - 2024-12-19
- Upgrades Petal Pro to LiveView 1.0.1!
- Admin/User AI chat - use LangChain to interrogate Petal Pro
- Content Editor component - based on Editor.js
- Blog/Content Management System - leveraging Content Editor
- Updated: Using latest Heroicons from Petal Components 2.0.6
- Updated: address gettext deprecation issue
- Updated: `petal.gen.live` uses Table instead of Data Table (and is based on streams). Use the `--data-table` option to generate templates using a Data Table
- Updated: Compatability increased for code generated by `phx.gen.live` and `phx.gen.html`
- Fixed: `sticky` class for stacked layout
- Fixed: Sub-menu will display for Stacked Layout in mobile mode
- Fixed: User notifications marked as read based on `socket` url (previously only worked with `conn` request path)
- Fixed: Combobox has rounded corners after selection
#### Upgrade Notes
In Petal Components, the `heroicons` dependency has been replaced with an alternate CSS-based approach. This is based on what has been implemented in the Phoenix repo - the reasoning is explained in this [issue](https://github.com/phoenixframework/phoenix/issues/5622). To upgrade an existing Petal Pro project, add the dependency in `mix.exs`:
mix.exs
```diff
def deps do
[
+ {:heroicons,
+ github: "tailwindlabs/heroicons",
+ tag: "v2.1.5",
+ app: false,
+ compile: false,
+ sparse: "optimized"},
]
end
```
This will download a copy of the source SVG files directly from GitHub (into `deps/heroicons/optimized`). Then the following code will process these files to create custom CSS classes:
assets/tailwind.config.js
```diff
const colors = require("tailwindcss/colors");
const plugin = require("tailwindcss/plugin");
+ const fs = require("fs");
+ const path = require("path");
module.exports = {
plugins: [
+ // Embeds Heroicons (https://heroicons.com) into your app.css bundle
+ // See your `CoreComponents.icon/1` for more information.
+ //
+ plugin(function({matchComponents, theme}) {
+ let iconsDir = path.join(__dirname, "../deps/heroicons/optimized")
+ let values = {}
+ let icons = [
+ ["", "/24/outline"],
+ ["-solid", "/24/solid"],
+ ["-mini", "/20/solid"],
+ ["-micro", "/16/solid"]
+ ]
+ icons.forEach(([suffix, dir]) => {
+ fs.readdirSync(path.join(iconsDir, dir)).forEach(file => {
+ let name = path.basename(file, ".svg") + suffix
+ values[name] = {name, fullPath: path.join(iconsDir, dir, file)}
+ })
+ })
+ matchComponents({
+ "hero": ({name, fullPath}) => {
+ let content = fs.readFileSync(fullPath).toString().replace(/\r?\n|\r/g, "")
+ let size = theme("spacing.6")
+ if (name.endsWith("-mini")) {
+ size = theme("spacing.5")
+ } else if (name.endsWith("-micro")) {
+ size = theme("spacing.4")
+ }
+ return {
+ [`--hero-${name}`]: `url('data:image/svg+xml;utf8,${content}')`,
+ "-webkit-mask": `var(--hero-${name})`,
+ "mask": `var(--hero-${name})`,
+ "mask-repeat": "no-repeat",
+ "background-color": "currentColor",
+ "vertical-align": "middle",
+ "display": "inline-block",
+ "width": size,
+ "height": size
+ }
+ }
+ }, {values})
+ })
],
};
```
### 2.0.0 - 2024-08-15
- Petal Framework is merged into Petal Pro
- Npm packages recipe is merged in as default
- Persistent user notifications
- Graphs/stats dashboard in the Admin console
- See who's currently active (via Presence) in the Admin console
- If user belongs to only one org, current org is automatically set
- `User.is_admin` is replaced with `User.role`. User role is an enum
- Integrate `:typed_ecto_schema` with `Ecto.Schema` fallback for users who have not installed it.
- Orgs are added to log view
- Ecto insights tab is enabled in LiveDashboard
- Fixed: Edge case for Combo Box - Tom Select is re-generated when there is a change in option count
- Fixed: App does not crash when impersonating a user and the session has expired
- Fixed: Subscription logs weren't working!
- Fixed: Race condition with subscription create/update when responding to Stripe web hooks
- Fixed: In docker compose, postgres container will not auto-restart if stopped
#### Upgrade Notes
Starting with this release, the Petal Framework is no longer referenced as an external package, and the private Petal hex repo it came from has since been shut down. If your Dockerfile has a `RUN --mount=type=secret,id=PETAL_LICENSE_KEY` step that adds that repo, delete the whole step and drop the `PETAL_LICENSE_KEY` build secret with it. Nothing replaces it, because nothing is fetched from petal.build at build time any more:
- Petal Pro itself is a zip you download from [petal.build/users/downloads](https://petal.build/users/downloads) after purchase. The code lives in your own repo.
- The components come from public Hex. Add `{:petal_components, "~> 4.17"}` to your deps in `mix.exs`, run `mix deps.get`, and put `use PetalComponents` in your web module.
You may need to add `nodejs` and `npm`:
Dockerfile
```diff
# install build dependencies
+ RUN apt-get update -y && apt-get install -y build-essential git nodejs npm \
+ && apt-get clean && rm -f /var/lib/apt/lists/*_*
```
In the past `mix assets.setup` would install Tailwind CSS and esbuild. Tailwind is now installed with `mix setup`, esbuild is installed via npm with `mix assets.deploy`. You'll need to remove:
Finally, `lib/petal_pro_web/petal_framework_translations.ex` is no longer required. Components like the DataTable can use Gettext directly.
### 1.8.0 - 2024-04-04
- JSON API: You can use the Petal Pro API for user management (register, sign in and update). It comes with OpenAPI support out of the box. Includes Swagger UI
- Update: Can sync all Stripe subscriptions including cancelled ones
- Added expanded user and org admin pages
- Fixed: PetalProWeb.Controllers.UserAuth.disconnect_user_liveviews doesn't disconnect the user's live views #216
- Fixed: Passwordless sign in issue from latest Phoenix Live View fixed #222
- Update: Sidebar layout now collapsible
### 1.7.0 - 2024-11-01
- Stripe integration - can buy subscriptions and manage them - support for both individuals and orgs
- Use `styler` for code formatting
- Updated landing page components to a more modern look
#### Upgrade Notes
Starting in this release, we now use [Styler](https://github.com/adobe/elixir-styler) to format our codebase. This means there will be a large amount of changes. To minimise merge or rebase conflicts when upgrading, we recommend you swap out Recode with Styler first:
Then, replace the content of `.credo.exs` with the one in this repo.
Finally, run the formatter for Styler to take care of things:
Another change we recommend you make before upgrading, especially if you've made changes to your landing page, is to rename `PetalProWeb.Components.LandingPage` to `PetalProWeb.LandingPageComponents`, make sure you also rename the file from `landing_page.ex` to `landing_page_components.ex`.
Given the amount of changes in this release, we recommend you backup your branch, then use `merge` instead of `rebase` to bring your branch up to date.
### 1.6.2 - 2023-11-03
- Fix bug where users registering via passwordless / 3rd parties would not get invites to orgs
### 1.6.1 - 2023-9-28
- Important passwordless security fix - anyone using passwordless should update
- Update deps
### 1.6.0 - 2023-7-05
#### New
- <.image_upload> component for uploading single images like avatars. Used in user settings
- Local, Cloudinary and S3 support for <.image_upload>
- User impersonation - admins can login as any user without knowing their password - available via the Admin console (under the User menu).
#### Updated
- All forms now use the new FormField structure
- <.public_layout> has been moved into public.html.heex (it's likely you'll want to modify this to your brand and hence a component doesn't make sense)
#### Fixed
- Reset password page now accessible when logged in (previously would redirect)
#### Removed
- Page builder (it was getting too complex to manage - let us know if you used this a lot and we'll consider bringing it back)
### 1.5.2 - 2023-4-20
#### New
- Uses the `petal_framework` private package (deletes all the `_petal_framework` folders). This will allow for an easier upgrade process in the future, especially for components like the data table.
- Data Table supports `base_url_params`. Keep custom query params when changing sort order.
- Data Table is now self contained in the live view - code isn't scattered across the model and context.
- Added `mix recode` for code linting and refactoring
- Use `<.flash_group>` to show flash messages (Petal Framework 0.3.0)
#### Changes
- Enabled Wallaby tests by default (`mix test`)
- Updated Tailwind to 3.3
- Updated Erlang to 25.3
- Added `rename_project` lib to replace custom mix task
#### Breaking
- Data table API has changed slightly. See our docs https://petal.build/components/data-table on how to use
#### Fixed
- Data table going blank when changing page size
- Navigation problems for the Data Table when setting the `default_limit` via a schema file
- Fix Finch issue with email sending
### 1.5.1 - 2023-3-10
#### New
- Develop Petal Pro in GitHub CodeSpaces!
- Data Table column - can now filter by a select list
- Data Table column - can now filter by a float
#### Changed
- topbar.js version updated to 2.0
- mix setup no longer fetches tailwind/esbuild if they already exist
- Upgrade Petal Components to 1.0
- Data Table is now a function component
#### Fixed
- Github auth working again
### 1.5.0 - 2023-2-10
#### Changed
- Upgraded Phoenix to 1.7
- Routes use the new verified routes
- Authentication pages converted to live views
- Upgraded fully from Hericons v1 to v2
- `petal.gen.live` now uses the Data Table component
- Tesla now uses the more secure Finch over Hackney (https://github.com/petalframework/petal_pro/issues/66)
- Confirmation page will redirect to org invitations if invitation exists (https://github.com/petalframework/petal_pro/issues/68)
- Removed Petal Enhance (it was more complex than we thought)
#### Fixes
- Redirect to `/app/orgs` if an invalid org slug is used (https://github.com/petalframework/petal_pro/issues/70)
- When editing user via `/admin/users` - `patch_back_to_index` no longer crashes (https://github.com/petalframework/petal_pro/issues/61)
- Always show Data Table filters (https://github.com/petalframework/petal_pro/issues/60)
### 1.4.1 - 2022-11-15 16:30:00
#### Added
- Add Petal Enhance (recipes)
#### Fixes
- Fix admin users modal. Clicking off the modal now works
- Change avatar_url to text in DB for long URLs
- Whitelist Google profile picture images in CSP
- Fix Mailbluster unsubscribe route + documentation
### 1.4.0 - 2022-10-12 23:44:20
#### Added
- Updated to LiveView 0.18 + Petal Components 0.18
- All components updated with declarative assigns (attr / slot)
- Data table component
- Local time component
- Sobelow for security checking
- Coveralls for code test coverage
- test.yml Github action for code quality
- Easily modifiable content security policy to help prevent XSS
- Added a docker-compose.yaml that adds Postgres so you don't need to install it
#### Changed
- Router significantly more streamlined
- Some routes have been moved into their own files: AdminRoutes, AuthRoutes, DevRoutes, MailblusterRoutes
- Users are forced to be confirmed to access /app routes (easily configurable)
- Use Ecto enums for org roles
#### Fixes
- Fix reset password failing when signed in
- Clean up dashboard_live.ex - some old code unused was left in there
- Improved SEO meta tags in _head.html.eex
- Show a warning in the logs when no title/meta_desciprion is set on a public page
- Added `open-graph.png` (to be replaced by dev)
- Fix require_confirmed_user plug
- Fix landing page GSAP not working
### 1.3.0 - 2022-06-17 02:43:55
#### Added
- Two-factor authentication using time-based one time passwords (paired with something like Google Authenticator)
#### Changed
- Decoupled DashboardLive from Orgs so you can get started quicker if you don't want orgs
- Can pass a custom header class to the public layout
- Sidebar and stacked layouts now support grouped menu items (see dev_layout_component.ex for an example)
- Update Tailwind to 3.1
- Split CSS into different files thanks to Tailwind 3.1
#### Fixed
- Onboarding now remembers user_return_to
- Fixed nav dropdown bug after modal toggle
- Fixed gettext in live views
### 1.2.0 - 2022-05-31 07:34:11
#### Added
- Login with Google & Github - easy to add more auth providers
- Passwordless auth - register/sign in via a code sent to your email
- Orgs - create an org, invite & manage members, and more
- User lifecycle actions - run code after actions like register, sign_in, sign_out, password_reset, etc
- New generator: mix petal.gen.html (same args as phx.gen.html)
- New component: <.markdown content=""> & <.pretty_markdown content=""> (uses Tailwind Typography plugin)
- Added License and Privacy pages (with some content from a template to get you started)
- New layout: <.layout type="public">, for public marketing related pages like landing, about us, privacy, etc
- Hooks can now be run in dead views if compatible (see color-scheme-hook.js as an example)
#### Changed
- Simpler config access (`PetalPro.config(:app_name)` instead of `Application.get_env(:petal_pro, :app_name)`)
- Refactor <.layout> to take less props
- Refactor dark/light mode system. Much simpler now and no longer needs cookies
- Put Petal Pro Components in their own folder for easier future upgrades (can duplicate if you want to modify them)
- Sidebar and stacked layout have a new slot for the top right corner (if you want to add something like a notifications bell)
#### Fixed
- Log metadata wasn't being cast
- More user actions are logged
- Fixed petal.live generator tests
- Added tests for user settings live views
### 1.1.1 - 2022-03-12 20:45:36
- Bump Oban version to stop random error showing
- Bump Petal Components
- Use new <.table> component in petal.gen.live generator & logs
- Dark mode persists on all pages with cookies
- Fix logo showing twice in emails
- Improved the Fly.io deploy flow
- Fix admin user search
- Remove guide (this is now online)
### 1.1.0 - 2022-02-28 00:08:52
- Added generator `mix petal.gen.live`
- Add gettext throughout public facing templates
- Improved dev_guide
- Add Oban
- Easy Fly.io deployment
---
# Upgrade Guide
# Source: https://petal.build/petal-pro/upgrade-guide
# Upgrade guide
How to upgrade your PetalPro project to the latest versions
Version updates can be a bit of a manual process. A boilerplate is meant to be a starting point for you to build from - rather than a framework like Phoenix. However, it is possible.
### 4.5.1 -> 4.5.2
Petal Pro 4.5.2 is a security patch for sign-in. The browser sign-in form had no limit at all, and now an account gets ten tries per ten minutes. Every limit that protects an account is now counted on the account, not on the email as typed, which closes a way round the 4.5.1 pin limit. Confirmation emails can't be resent without limit, and an admin can no longer impersonate a user before finishing two-factor. There are no migrations, no dependency changes and no new settings. Users see one new cookie, and "Too many attempts" where a limit refuses.
If you never customised the files below, the work is: take the ten changed `lib/` files, replace `test/petal_pro_web/controllers/user_passkey_controller_test.exs`, add the new cookie to your cookie policy, and run the checks in step 6. On 4.5.0 or older, start at step 8.
⚠️ Warning: 4.5.2 needs 4.5.1 underneath. On 4.5.0 with every file below, mix compile warns that UserPin.check_pin/3 is undefined (it arrived in 4.5.1), and entering a passwordless pin crashes. The new controllers call PetalProWeb.ClientIp.rate_limit_key/2, also from 4.5.1: take one without the new client_ip.ex and API sign-in and registration fail with a 500 on every request, and browser password and passkey sign-in do once CLIENT_IP_HEADER or TRUSTED_PROXY_HOPS is set. Either way you would be without 4.5.1's own fixes. And if you merge user_session_controller.ex by hand, check the three steps marked "don't skip" in step 3. Skip one and nothing raises an error, but the limit doesn't do its job. Comparing the password before counting gives no sign at all. Leaving out the clear or the remember call only leaves an "unused function" warning from mix compile, which --warnings-as-errors turns into a failure.
#### 1. Take the changed files
Every file the release changes, grouped by fix. Each changed file works next to the 4.5.1 version of every other file, so you can take them one at a time. A file you leave behind leaves its own fix out, with one catch: the API half of the reset fix in `user_reset_password_live.ex` only works with the new API `session_controller.ex`.
The `test/` files are optional but worth having: they prove each limit holds. A test needs the `lib/` files of its group, and the few that need a file from another group say so. The one test you must replace is `test/petal_pro_web/controllers/user_passkey_controller_test.exs`. Its 4.5.1 copy has a test, "the eleventh attempt from one address within a minute goes back to sign-in with a message", that fails against the new passkey controller, because with no client address set that limit no longer applies. The 4.5.2 copy moves that test into `client_ip_test.exs`, which sets an address first. The tests use `test/support/rate_limit_helpers.ex` from 4.5.1, unchanged.
**Browser password sign-in limit** (the two `lib/` files run without each other):
- `lib/petal_pro_web/controllers/user_session_controller.ex` (the limits, the trusted-browser cookie, and a malformed post answered as a failed sign-in instead of a 500)
- `lib/petal_pro_web/live/auth/user_reset_password_live.ex` (a password reset starts the account's browser and API sign-in counts again; the API half needs the new API `session_controller.ex` from the next group, because the 4.5.1 one counts on the email text, not the account)
- `test/petal_pro_web/controllers/user_session_controller_test.exs`
- `test/petal_pro_web/controllers/user_session_address_limit_test.exs` (new; its IPv6 test needs the new `client_ip.ex`)
- `test/petal_pro_web/live/auth/user_reset_password_live_test.exs` (needs the new `user_session_controller.ex` and the new API `session_controller.ex` too)
**Account limits counted on the account** (each file works on its own):
- `lib/petal_pro_web/live/auth/passwordless_auth_live.ex`
- `lib/petal_pro_api/controllers/session_controller.ex`
- `lib/petal_pro_web/live/auth/user_forgot_password_live.ex`
- `test/petal_pro_web/live/passwordless_auth_live_test.exs`
- `test/petal_pro_api/session_controller_test.exs`
- `test/petal_pro_web/live/auth/user_forgot_password_live_test.exs`
**Impersonation with a second factor pending:**
- `lib/petal_pro_web/controllers/user_impersonation_controller.ex`
- `test/petal_pro_web/controllers/pending_two_factor_test.exs` (new)
**Confirmation email resends** (one count, shared by the two doors):
- `lib/petal_pro_web/live/auth/user_confirmation_instructions_live.ex`
- `lib/petal_pro_api/controllers/registration_controller.ex`
- `test/petal_pro_web/live/auth/user_confirmation_instructions_live_test.exs` (one test resends through the API, so it needs the new `registration_controller.ex` too)
- `test/petal_pro_api/registration_controller_test.exs`
**IPv6 counted by /64, and the passkey limit only with a client address:**
- `lib/petal_pro_web/client_ip.ex`
- `lib/petal_pro_web/controllers/user_passkey_controller.ex`
- `test/petal_pro_web/client_ip_test.exs` (its passkey tests need the new passkey controller)
- `test/petal_pro_web/controllers/user_passkey_controller_test.exs` (replace your 4.5.1 copy, see above)
**Comments, docs and recipes:** `config/runtime.exs` (the comment above the client IP settings), `DEPLOYMENT.md`, `CHANGELOG.md`, `CLAUDE.md`, `AGENTS.md`, `.claude/commands/recipes/add-saml-sso.md` (where the SSO check goes now), `.claude/commands/recipes/remove-2fa.md` (what to keep in the new impersonation check) and `mix.exs` (`@version` only). Nothing in them changes behaviour.
#### 2. Tell the app which address is the client's
The account limits need no setting. Four limits count per address. Two of them, browser sign-in (100 failed tries per ten minutes from one address, across every account) and passkey sign-in (10 a minute), only apply since 4.5.2 once the app knows the client's address. That means `CLIENT_IP_HEADER` or `TRUSTED_PROXY_HOPS` is set, and the request's address came from it rather than falling back to the peer. Without either, every visitor behind your proxy has the proxy's address, and one caller could use the count up for all of them, so the app leaves those two limits off. The other two, API sign-in (5 a minute) and API registration (3 an hour), count per address as they did in 4.5.1, so without a setting each is one budget for your whole app.
If you set one of these for 4.5.0 or 4.5.1, you're done here. If you didn't, step 2 of the [4.5.0 -> 4.5.1 upgrade](#4-5-0-4-5-1) shows the setting for Fly, Cloudflare and nginx. Until you do, each machine logs one warning per boot, at the first password sign-in that arrives with proxy headers (step 4 has the text), and a script trying one password against many accounts is only limited per account.
#### 3. If you customised these files
- **`user_session_controller.ex`** - its code was the same in every 4.x release up to 4.5.1, so anything different in yours is your own change. The simplest way is to take the new file and put your change back in the right place:
- A check that has to run before the password is compared, like the SSO rule from the SAML recipe (`check_sso_enforcement/1`), goes in `sign_in/6`, inside the `{:ok, counted}` branch and before `check_password/6`. A comment marks the place. There the attempt has already been counted, and a malformed post never gets that far. Don't put it in `create/3` or before `count_sign_in/4`, where it would run for attempts nobody counts.
- Something for a successful sign-in, like an extra log line, goes in the success branch of `check_password/6`, after `clear_sign_in_limits(counted)` and before the `conn` pipeline. Don't set session data there: `UserAuth.log_in_user/3` renews the session, which clears it, and the response has been sent by the time it returns. Session data that should survive sign-in belongs in `UserAuth.put_user_into_session/2`, after `renew_session/1`. Every sign-in goes through it, and so does impersonation.
- Something for a failed sign-in goes in the `else` branch of `check_password/6`.
If you'd rather merge into your own copy, bring over the `PetalPro.RateLimiter` and `PetalProWeb.ClientIp` aliases and `require Logger`, the seven module attributes from `@window` to `@device_entries`, the two private `create/3` clauses (they replace the old one, whose password check moves into `check_password/6`), and every private function from `sign_in/6` to the end of the module. `create/2`, `delete/2` and `create_from_token/2` don't change. Then check these three. **Don't skip them.** None raises an error when it's missing. The first gives no warning at all, and the other two only an "unused function" warning, so also run `mix compile --warnings-as-errors`.
1. **Count before you compare.** `count_sign_in/4` runs before `Accounts.get_user_by_email_and_password/2`. Compare first and the limit stops nothing, because the right password gets in however many wrong ones came before it.
2. **Clear the counts on success.** Keep `clear_sign_in_limits(counted)` in the success branch, with the `@dialyzer {:nowarn_function, clear_sign_in_limits: 1}` line above the function. Skip it and a user who signs in ten times in ten minutes is refused for their own successes, and the address count counts successes as well as failures.
3. **Remember the browser on success.** Keep `remember_device/2` in the success branch. Skip it and no browser is ever trusted, so anyone who knows an email can lock its owner out of password sign-in on every browser.
- **`user_reset_password_live.ex`** - in `handle_event("reset_password", ...)`, keep the user from the `{:ok, _}` branch and clear its counts:
```diff
- {:ok, _} ->
+ {:ok, user} ->
+ clear_sign_in_limit(user)
+
```
Then add the helper. The keys are the ones the browser and API sign-in count on, and the window has to match theirs:
```elixir
@dialyzer {:nowarn_function, clear_sign_in_limit: 1}
defp clear_sign_in_limit(user) do
PetalPro.RateLimiter.set("web_sign_in_account:" <> user.id, to_timeout(minute: 10), 0)
PetalPro.RateLimiter.set("api_sign_in_account:" <> user.id, to_timeout(minute: 10), 0)
end
```
- **`passwordless_auth_live.ex`** - the pin limit is now counted on the account, so `send_pin/2` finds or creates the account first. Move `Accounts.get_or_create_user/2` to the top of the `with`, hit the limit on the user, and move the `{:deny, _retry_after}` clause (with its "Too many attempts" message) into the `else`. Then key on the id. This replaces the lower-casing from step 3 of the 4.5.1 upgrade:
```elixir
with {:ok, user} <- Accounts.get_or_create_user(%{email: email}, "passwordless"),
{:allow, _count} <- PetalPro.RateLimiter.hit(pin_limit_key(user), to_timeout(minute: 10), 3),
pin when not is_nil(pin) <- UserPin.create_pin(user),
{:ok, email} <- UserMailer.deliver_passwordless_pin(user, pin) do
# ...
defp pin_limit_key(%User{id: id}), do: "passwordless_pin:" <> id
```
- **Every file that counts an email with no account** (`user_session_controller.ex`, the API `session_controller.ex`, `user_forgot_password_live.ex`, `user_confirmation_instructions_live.ex` and the API `registration_controller.ex`) - each has its own copy of this helper, on purpose, so no file needs another. It lets the database fold the text the way the `email` column compares it, and hashes anything longer than an email can be:
```elixir
defp limit_email(email) do
%{rows: [[folded]]} = PetalPro.Repo.query!("SELECT lower($1::text)", [String.trim(email)])
if byte_size(folded) <= 320 do
folded
else
"sha256:" <> Base.url_encode64(:crypto.hash(:sha256, folded), padding: false)
end
end
```
- **The API `session_controller.ex`** - look the account up in `hit_account_limit/1` and key on it, and clear by user. In `create/2`, `clear_account_limit(email)` becomes `clear_account_limit(user)`. Keep the `@dialyzer` line above `clear_account_limit/1`:
```elixir
defp hit_account_limit(email) when is_binary(email) do
text = limit_email(email)
key =
case Accounts.get_user_by_email(String.trim(email)) do
%User{} = user -> account_limit_key(user)
nil -> "api_sign_in_unknown:" <> text
end
PetalPro.RateLimiter.hit(key, @account_window, 10)
end
defp clear_account_limit(user), do: PetalPro.RateLimiter.set(account_limit_key(user), @account_window, 0)
defp account_limit_key(%User{id: id}), do: "api_sign_in_account:" <> id
```
- **`user_forgot_password_live.ex`** - look the user up before the hit, with `String.trim/1`, and use that `user` in the `{:allow, _}` branch instead of looking it up again. Add `alias PetalPro.Accounts.User`, add `when is_binary(email)` to the `send_email` handler, and a catch-all after it: `def handle_event("send_email", _params, socket), do: {:noreply, socket}`. The key:
```elixir
user = Accounts.get_user_by_email(String.trim(email))
case PetalPro.RateLimiter.hit(reset_limit_key(user, email), to_timeout(minute: 10), 3) do
# ...
defp reset_limit_key(user, email) do
text = limit_email(email)
case user do
%User{id: id} -> "password_reset:" <> id
nil -> "password_reset_unknown:" <> text
end
end
```
- **`user_confirmation_instructions_live.ex` and the API `registration_controller.ex`** - both get the same new limit, and they must use the same key strings or the two doors get a count each. In the LiveView, look the user up with `String.trim/1`, wrap the send and its flash in `PetalPro.RateLimiter.hit(confirm_limit_key(user, email), to_timeout(minute: 10), 3)`, and on `{:deny, _}` put the error flash "Too many attempts. Please try again later." and redirect to `~p"/"`, the same page as a send. Add the `is_binary(email)` guard and a catch-all clause as above. Add `alias PetalPro.Accounts.User` to both files, because the key below matches on it. In the API controller, add `plug :rate_limit_send_instructions when action in [:send_instructions]` and copy `rate_limit_send_instructions/2` from the 4.5.2 file: it answers a refusal with a 429 and leaves a request with no `email` to the action. Both use this key:
```elixir
defp confirm_limit_key(user, email) do
text = limit_email(email)
case user do
%User{id: id} -> "confirm_instructions:" <> id
nil -> "confirm_instructions_unknown:" <> text
end
end
```
- **`user_impersonation_controller.ex`** - add the plug and its function:
```elixir
plug :require_completed_sign_in when action in [:create]
# ...
defp require_completed_sign_in(conn, _opts) do
cond do
get_session(conn, :user_passkey_pending) ->
conn |> redirect(to: ~p"/app/users/passkey-verify") |> halt()
get_session(conn, :user_totp_pending) ->
conn |> redirect(to: ~p"/app/users/totp") |> halt()
true ->
conn
end
end
```
If you removed 2FA with the recipe, delete only the `:user_totp_pending` clause (its route is gone) and keep the passkey one. If you have routes of your own piped through `:require_admin_user` without `:require_authenticated_user` (or the `:authenticated` pipeline), add it: `:require_admin_user` doesn't look at a pending second factor, so those routes have the same hole.
- **`user_passkey_controller.ex`** - wrap the `passkey_auth` hit in `rate_limit/2` in `if address_limited?(conn) do ... else conn end`, and copy `address_limited?/1` and `peer/1` from the 4.5.2 file. They are the same two functions as in `user_session_controller.ex`.
- **`client_ip.ex`** - bring over the private `resolve/2`, `group/1` and `ipv4/2` and the new body of `rate_limit_key/2`. `get/2` returns exactly what it did, so `last_signed_in_ip` and the audit log still hold the full address.
- **A limit of your own on an email** - if you added one (on a form that sends mail, say), look the account up and key on `user.id`, the way the stock files do now. A key built from the typed text, even lower-cased, gets a fresh count for every spelling the database treats as the same email. See [Rate Limiting](/petal-pro/fundamentals/deployment#counted-on-the-account).
#### 4. What your users will notice
- **Browser sign-in:** ten tries per ten minutes per account, from any browser that hasn't signed in to it before. The eleventh is refused even with the right password: the user lands back on the sign-in page with "Too many attempts. Please try again later." and waits for the window to end, ten minutes at most (the windows line up with the clock). A correct password counted on the account starts the count again. A sign-in from a trusted browser (next point) doesn't touch the account's count, so other browsers stay refused until the window ends or the password is reset. An email with no account gets exactly the same answer, so a refusal doesn't show which emails have accounts.
- **A new cookie.** A successful password sign-in sets `_petal_pro_web_sign_in_device`: encrypted, HttpOnly, SameSite=Lax, kept for one year, and `Secure` over https. A browser that holds it for an account gets ten tries of its own first and then the account's ten, so a stranger who uses up the account's count can't lock the owner out of the browser they normally use. It grants no access, remembers up to five accounts on a shared computer, and stops counting for an account once that account's password changes. List it in your cookie policy as a security cookie. See [Trusted Browsers](/petal-pro/fundamentals/deployment#trusted-browsers).
- **Password reset gets a locked-out user back in.** A successful reset starts the account's browser and API sign-in counts again, on the machine that serves the reset. It also ends the trust of every browser that signed in under the old password.
- **Confirmation emails:** the fourth resend for one account within ten minutes is refused. The form goes to the home page with "Too many attempts. Please try again later." and `POST /api/send-instructions` gets a 429 with `{"errors": {"detail": "Too many requests"}}`. The two share one count. An email with no account, and one already confirmed, spend it the same way.
- **Password reset requests:** still three per ten minutes, now per account, so every capitalisation of one email shares a count. In 4.5.1 the count was on the text exactly as typed.
- **Passkey sign-in:** with neither `CLIENT_IP_HEADER` nor `TRUSTED_PROXY_HOPS` set, it's no longer limited per address. With one set, it's 10 a minute per address as before.
- **Admins with two-factor:** an admin who has typed their password but not their code is sent to the code step (`/app/users/totp` or `/app/users/passkey-verify`) if they try to impersonate. After the code, impersonation works as before.
- **A malformed sign-in post** (no email, or a list where text should be) gets "Invalid email or password" instead of a 500, and isn't counted.
- **Your logs:** with neither address setting made, the first sign-in after each boot that arrives with a proxy header (`x-forwarded-for`, `fly-client-ip` or `cf-connecting-ip`) logs `Browser sign-in has no per-address limit: proxy headers are present but neither CLIENT_IP_HEADER nor TRUSTED_PROXY_HOPS is set. See DEPLOYMENT.md.` Fly adds `fly-client-ip` to every request, so on Fly each machine logs it once after every boot until you set the header. A refused count also logs `Browser sign-in refused: too many attempts ...` once per count per window. It names the account id, or says the email has no account, or gives the address key. It never logs the email.
- **Your test suite:** a test that posts more than ten wrong passwords for one account within ten minutes now gets the refusal. Give each test its own user, as the fixtures do. A test that drives a count right up to its limit can call `PetalPro.RateLimitHelpers.stay_in_window/1` first, so the window doesn't end halfway through.
#### 5. Clear a locked account by hand
The counts live in memory on each machine, so a restart or a deploy clears them all. To clear one account without that, open a remote IEx shell on each machine. On Fly, pick each machine in turn:
```shell
fly ssh console --app your-app-name --select
/app/bin/your_app remote
```
Then:
```elixir
user = PetalPro.Accounts.get_user_by_email("someone@example.com")
PetalPro.RateLimiter.set("web_sign_in_account:" <> user.id, to_timeout(minute: 10), 0)
PetalPro.RateLimiter.set("api_sign_in_account:" <> user.id, to_timeout(minute: 10), 0)
```
The window has to be the one the limit uses, ten minutes here, or you set a different count. Asking the user to reset their password does the same on the machine that serves the reset.
#### 6. Check it worked
1. If you took the test files, run them, for example `mix test test/petal_pro_web/controllers/user_session_controller_test.exs test/petal_pro_web/controllers/pending_two_factor_test.exs test/petal_pro_web/controllers/user_passkey_controller_test.exs`. Name only files you have: `mix test` skips a path that doesn't exist without saying so, and a 4.5.1 copy of a test tests none of the new limits. If you took only the `lib/` files and the passkey test, run the whole suite with `mix test`. It should pass, but it doesn't test the new limits, so checks 3 to 7 are your proof
2. Run the next checks locally, or on one machine. With several, the count is per machine and a refusal can take more tries
3. In your normal browser, sign in with a password once, then sign out. Your browser's dev tools should show the `_petal_pro_web_sign_in_device` cookie, HttpOnly, SameSite Lax, expiring in a year
4. Open a private window and sign in to the same account with a wrong password ten times. Each should say "Invalid email or password". Then try the right password: it should say "Too many attempts. Please try again later." If the right password signs you in instead, the tries crossed a ten-minute boundary on the clock, so try again
5. Back in your normal browser, the right password should sign you in. That's the cookie doing its job. It doesn't clear the account's count, so the private window is still refused
6. Clear the count from check 4 with the snippet in step 5 ("Clear a locked account by hand"). Locally, if you started the server with `iex -S mix phx.server`, paste it into that shell; otherwise restarting the server clears every count. Or wait ten minutes
7. On `/auth/confirm`, ask for the confirmation email four times for the same address. The fourth should say "Too many attempts". Locally, the ones that were sent land in `/dev/mailbox`
8. In production, after the deploy and once someone has signed in with a password, look for the "Browser sign-in has no per-address limit" warning in your logs. It's logged at the first such sign-in on each machine, not at boot. If it's there, do step 2. No warning doesn't prove the per-address limit is on: with a header set that your proxy doesn't send, every request falls back to the peer and the limit stays off without a warning. Check `last_signed_in_ip` on your own user shows your public address
#### 7. What still isn't limited
4.5.2 doesn't limit these. Put a limit in front of them yourself if your app is a target, or use your proxy's rate limiting:
- **Browser registration** (`/auth/register`), and the account passwordless sign-in creates for a new email. Each one sends an email to the address it was given. Resends are limited now; the first email isn't.
- **Email a signed-in user can send** by changing their email address or inviting people to an org.
- **The current-password check on the settings pages**, for someone who already has a signed-in session.
And with no client address setting, a script trying one password against many accounts is only limited per account. Step 2 adds a per-address limit on top, which slows one source down but doesn't stop a caller with many addresses.
#### 8. On an older 4.x version
4.5.2 is built on 4.5.1. On 4.5.0, do the [4.5.0 -> 4.5.1 upgrade](#4-5-0-4-5-1) first, then this one. On 4.4.0 or older, work up through each section below.
If you can't do that yet, some of the fixes don't need 4.5.x. The first three files below have the same code in every 4.x release up to 4.5.1, and their new code only calls functions every 4.x has. The fourth needs one 4.5.1 file beside it:
- `lib/petal_pro_web/controllers/user_impersonation_controller.ex` - the impersonation fix. On 4.0.x, which has no passkeys, delete the `:user_passkey_pending` clause from `require_completed_sign_in/2`, or `mix compile` warns that no route matches `/app/users/passkey-verify`.
- `lib/petal_pro_web/live/auth/user_forgot_password_live.ex` - the reset request limit, per account.
- `lib/petal_pro_web/live/auth/user_confirmation_instructions_live.ex` - the resend limit on the browser form. The API side is in `registration_controller.ex`, which needs 4.5.1.
- `lib/petal_pro_web/live/auth/passwordless_auth_live.ex` - the pin limit on the account, together with `lib/petal_pro/accounts/user_pin.ex` from 4.5.1. Step 6 of the 4.5.1 upgrade covers that pair.
The browser sign-in limit waits for 4.5.1. `user_session_controller.ex` calls `PetalProWeb.ClientIp`, new in 4.5.0, and its `rate_limit_key/2`, new in 4.5.1. Before 4.5.0 it compiles with two warnings (`PetalProWeb.ClientIp.get/1` and `rate_limit_key/2` are undefined), which fail `mix compile --warnings-as-errors`. Your tests can still pass, so don't read that as safe: the warning it logs on Fly tells you to set `CLIENT_IP_HEADER`, which does nothing before 4.5.0. On 4.5.0 without the new `client_ip.ex` beside it, it compiles with one warning (`rate_limit_key/2` is undefined), and once a client address setting is made it is the 500 in the warning above. `user_reset_password_live.ex` is safe on any 4.x, but without the new sign-in controller it clears a browser count nothing reads, and without the new API `session_controller.ex` it clears an API count nothing reads. The API controllers, `client_ip.ex` and the passkey controller build on 4.5.1 too.
The tests were written against 4.5.1, and all but `pending_two_factor_test.exs` need `test/support/rate_limit_helpers.ex` from it. Before 4.5.0, also change every `[role=alert]` in `passwordless_auth_live_test.exs` to `[role=dialog]` (there are six in the 4.5.2 copy), or five of its tests fail even though the fix works. And expect one test in `user_confirmation_instructions_live_test.exs`, the one that resends through the API, to fail until you have the 4.5.2 `registration_controller.ex`, which needs 4.5.1.
---
### 4.5.0 -> 4.5.1
Petal Pro 4.5.1 is a security patch. It closes four ways round the sign-in rate limits: a passwordless pin could be guessed without limit, two-factor codes had no limit at all, API sign-in was only limited per address, and the API and passkey limits counted your proxy instead of the visitor. There are no migrations and no dependency changes. The only UI change is a "Too many attempts" message where a limit refuses.
If you never customised the files below, the work is: take the seven changed `lib/` files and `test/petal_pro/user_pin_test.exs`, set `CLIENT_IP_HEADER` or `TRUSTED_PROXY_HOPS` if you haven't since 4.5.0, and run the check in step 5. On 4.4.0 or older, start at step 6.
⚠️ Warning: take user_pin.ex and passwordless_auth_live.ex together. The new LiveView calls UserPin.check_pin/3, which only exists in the new user_pin.ex. With only the new LiveView, mix compile prints a warning and every pin submit crashes, so passwordless sign-in stops working. Likewise take client_ip.ex with any of the session, registration or passkey controllers: they call PetalProWeb.ClientIp.rate_limit_key/2, and without it every API sign-in, API registration and passkey sign-in attempt is a 500.
#### 1. Take the changed files
Every file the release changes, grouped by fix. The `test/` files are optional but worth having: they prove each limit holds. The one exception is `test/petal_pro/user_pin_test.exs`: take it with the new `user_pin.ex`, because the 4.5.0 version fails against it.
**Passwordless pin limit** (take both `lib/` files together):
- `lib/petal_pro/accounts/user_pin.ex`
- `lib/petal_pro_web/live/auth/passwordless_auth_live.ex`
- `test/petal_pro/user_pin_test.exs` (not optional, see above)
- `test/petal_pro_web/live/passwordless_auth_live_test.exs`
**Two-factor limit:**
- `lib/petal_pro_web/controllers/user_totp_controller.ex`
- `test/petal_pro_web/controllers/user_totp_controller_test.exs`
**API sign-in per-account limit, and the API and passkey limits keyed on the client:**
- `lib/petal_pro_web/client_ip.ex` (adds `PetalProWeb.ClientIp.rate_limit_key/2`, which the three controllers below call, so take it with any of them)
- `lib/petal_pro_api/controllers/session_controller.ex` (both the client key and the per-account limit)
- `lib/petal_pro_api/controllers/registration_controller.ex`
- `lib/petal_pro_web/controllers/user_passkey_controller.ex` (also stops counting the challenge request and answers a refusal with a redirect)
- `test/petal_pro_web/client_ip_test.exs`
- `test/petal_pro_api/session_controller_test.exs`
- `test/petal_pro_api/registration_controller_test.exs`
- `test/petal_pro_web/controllers/user_passkey_controller_test.exs`
**Shared by the tests above:** `test/support/rate_limit_helpers.ex` (new). Take it if you take any of the tests that use it.
**Comments, docs and the version number:** `config/runtime.exs` (the comment above the client IP settings), `DEPLOYMENT.md`, `CHANGELOG.md` and `mix.exs` (`@version` only). Nothing in `runtime.exs` changes behaviour.
#### 2. Tell the app which address is the client's
The API sign-in, API registration and passkey limits now count the address `PetalProWeb.ClientIp` resolves, the same one `last_signed_in_ip` records since 4.5.0. Until you set `CLIENT_IP_HEADER` or `TRUSTED_PROXY_HOPS` that is still the peer, so behind a proxy every visitor keeps sharing one budget. If you did step 5 of the 4.5.0 upgrade, you're done here.
On Fly:
fly.toml
```toml
[env]
CLIENT_IP_HEADER = "fly-client-ip"
```
Behind Cloudflare use `CLIENT_IP_HEADER=cf-connecting-ip`. Behind one nginx or Caddy use `TRUSTED_PROXY_HOPS=1`. Only name a header your proxy overwrites on every request, and make sure the app's port can't be reached around the proxy, or a caller can pick their own address and dodge the limits.
#### 3. If you customised these files
- **`passwordless_auth_live.ex`** - if you'd rather keep your own LiveView, make these six changes to it:
1. Swap the `UserPin.validate_pin/3` call for `UserPin.check_pin/3`.
2. Delete the `UserPin.failed_attempt/1` call after it. `check_pin/3` counts the attempt itself.
3. Route your "Resend" handler through `send_pin/2`, so a resend hits the same limit as the first request.
4. Add `enable_resend?: false` to the assigns `send_pin/2` sets when it sends. The resend handler no longer does it.
5. Lower-case the email in the limit key.
6. Add `when is_binary(email)` to your `submit_email` handler, and a catch-all after it: `def handle_event("submit_email", _params, socket), do: {:noreply, socket}`. Without it an email that isn't text crashes the LiveView, and the 4.5.1 `passwordless_auth_live_test.exs` has one failing test.
If you only take `user_pin.ex` for now, your old calls keep working: `validate_pin/3` now counts the attempt and `failed_attempt/1` does nothing, so each pin keeps its three guesses. That's a stopgap, not the fix: until the LiveView changes too, "Resend" still skips the request limit and each capitalisation still gets its own count. The deprecation warnings also fail `mix compile --warnings-as-errors`, which Pro's CI runs. `UserPin.increment_changeset/1` is gone.
- **A copied `rate_limit` plug** - if you copied one of the stock plugs into your own controllers, swap its `conn.remote_ip` line for the new key:
```diff
- ip = conn.remote_ip |> :inet.ntoa() |> to_string()
-
- case PetalPro.RateLimiter.hit("my_action:#{ip}", to_timeout(minute: 1), 10) do
+ case PetalPro.RateLimiter.hit(PetalProWeb.ClientIp.rate_limit_key(conn, "my_action"), to_timeout(minute: 1), 10) do
```
- **`session_controller.ex`, `user_totp_controller.ex`, `user_passkey_controller.ex`, `registration_controller.ex`** - if you edited these, merge the `rate_limit` plug and its helpers by hand. Both reset helpers call `PetalPro.RateLimiter.set/3` with a count of zero. Bring the `@dialyzer {:nowarn_function, ...}` line above each one too: Hammer's spec says the count is positive, so dialyzer flags a zero. Then add the reset calls: `clear_account_limit(email)` on a successful API sign-in in `SessionController.create/2`, and `clear_rate_limit(current_user)` in both the `:valid_totp` and `:valid_backup_code` branches of `UserTOTPController.create/2`. Skip them and nothing errors, legitimate users just get refused. In the passkey controller the plug guard is now `when action in [:create]`, without `:challenge`. `registration_controller.ex` only needs the key swap shown above.
#### 4. What your users will notice
- **Two-factor:** five codes per five minutes per user, backup codes included. Every submit counts and a correct code resets the count. The sixth try in the window gets a 429 and the code form with "Too many attempts. Please try again later."
- **API sign-in:** on top of 5 a minute per address, ten tries per ten minutes per email, whatever address they come from. A successful sign-in resets that count. A refused request gets a 429 with `{"errors": {"detail": "Too many requests"}}`, same as before. 4.5.2 closes a way round this: on some databases the same account could be reached under another spelling of its email, each with a count of its own. On 4.5.2 the count is kept on the account.
- **Passkey sign-in:** loading the sign-in page no longer uses up the budget. Past 10 attempts a minute, the user lands back on the sign-in page with "Too many attempts. Please try again later." where they used to get a 500.
- **Passwordless:** "Resend" counts toward the three pin requests per ten minutes, so after the first pin and two resends a user waits for the window to end. Each pin still allows three guesses, so that's nine guesses per account per ten-minute window. The same email in different capitals now shares one count. 4.5.2 closes a way round this: on some databases the same account could be reached under another spelling of its email, each with a count of its own. On 4.5.2 the count is kept on the account.
#### 5. Check it worked
1. Run the test files you took, for example `mix test test/petal_pro/user_pin_test.exs test/petal_pro_web/controllers/user_totp_controller_test.exs`
2. In production, sign in and check `last_signed_in_ip` on your user is your own public address, not your proxy's. That's the address the API sign-in, API registration and passkey limits count
3. Sign in with a 2FA user and enter six wrong codes. The first five are refused as wrong codes and the sixth should show "Too many attempts". Don't mix a correct code in, because it starts the count again. Wait five minutes before you try again. Run this and the next check locally or on one machine: with several, the count is per machine and the refusal can take more tries
4. On a passwordless sign-in, ask for a pin, then enter a wrong pin and hit "Resend" (it only shows after a wrong pin). Do that twice more. The third resend should show "Too many attempts"
The limits live in memory on each machine, so with two machines a caller gets twice the number.
#### 6. On an older 4.x version
The pin and two-factor fixes don't need 4.5.0. They are in three files whose code hasn't changed since 4.0.0:
- `lib/petal_pro/accounts/user_pin.ex`
- `lib/petal_pro_web/live/auth/passwordless_auth_live.ex`
- `lib/petal_pro_web/controllers/user_totp_controller.ex`
Take those from 4.5.1 together with `test/petal_pro/user_pin_test.exs`, because every older copy of that test fails against the new `user_pin.ex`. They need no other file, setting or migration. We ran this on 4.0.0, 4.1.0, 4.2.0, 4.3.0 and 4.4.0, and the whole test suite passes on each.
- **The other two tests are optional, with one catch.** `test/petal_pro_web/live/passwordless_auth_live_test.exs` and `test/petal_pro_web/controllers/user_totp_controller_test.exs` both need `test/support/rate_limit_helpers.ex`. The passwordless test also looks for `[role=alert]`, and before 4.5.0 the petal_components alert renders `role="dialog"`. Change every `[role=alert]` in your copy to `[role=dialog]` (there are five), or four of its tests fail even though the fix works.
- **The API and passkey fixes need 4.5.0 first.** They build on `PetalProWeb.ClientIp`, which arrived in 4.5.0, so upgrade to 4.5.0 before you take those controllers. Before 4.5.0, `CLIENT_IP_HEADER` and `TRUSTED_PROXY_HOPS` do nothing.
---
### 4.4.0 -> 4.5.0
Petal Pro 4.5.0 is mostly a UI release. The settings, billing, two-factor and account deletion screens are rebuilt on petal_components, flash messages become toasts, empty states and status pills each use one shared component, and Tom Select is gone. petal_components moves from 4.6.0 to 4.18.0. Two changes are on the server side: sign-ins record the real client IP behind a proxy you trust, and production forces https with Secure cookies.
If you take 4.5.0 the normal way and never customised the files named below, the work is: update petal_components, add one line to `fly.toml` if you deploy on Fly, fix any HTTP health check you added yourself, and click through the screens at the end. The steps are in the order to do them.
⚠️ Warning: if you deploy on Fly, add CLIENT_IP_HEADER = "fly-client-ip" to the [env] block of fly.toml. Without it, every sign-in records Fly's proxy address. If you added an HTTP health check, give it an X-Forwarded-Proto: https header or exclude its path, or it gets a 301. Default TCP checks are unaffected. Both are covered in step 5.
#### 1. Take Pro 4.5.0, then update petal_components
Pro 4.5.0 requires `petal_components ~> 4.18`. Merge the release into your project first, then run:
```shell
mix deps.update petal_components
```
Expect petal_components 4.18.0 or later. Check with `mix deps | grep petal_components`.
Do it in that order. petal_components now ships free versions of several names Pro used to define itself (`combo_box` from 4.12, `data_table` from 4.13, and the four components in step 3), so 4.4.0 code on the new library fails with a "call is ambiguous" error. Pro 4.5.0 deletes its own copies where the free one replaces it, and keeps its own Flop-driven `data_table` by importing the free module with `except:`. If you edited `PetalProComponents`, make sure its imports match 4.5.0:
lib/petal_pro_web/components/pro_components.ex
```elixir
import PetalComponents.ColorSchemeSwitch
import PetalComponents.ComboBox
import PetalComponents.DataTable, except: [data_table: 1]
import PetalComponents.LanguageSelect
import PetalComponents.LocalTime
import PetalComponents.SocialButton
import PetalProWeb.AuthLayout
import PetalProWeb.ContentEditor
import PetalProWeb.DataTable, only: [data_table: 1]
import PetalProWeb.Flash
import PetalProWeb.Markdown
import PetalProWeb.Navbar
import PetalProWeb.PageComponents
import PetalProWeb.RouteTree
import PetalProWeb.SidebarLayout
import PetalProWeb.StackedLayout
import PetalProWeb.StatusBadge
```
Compared with 4.4.0 that drops `PetalProWeb.ColorSchemeSwitch`, `PetalProWeb.ComboBox`, `PetalProWeb.LanguageSelect`, `PetalProWeb.LocalTime` and `PetalProWeb.SocialButton`, and adds the six `PetalComponents.*` lines and `PetalProWeb.StatusBadge`.
The release also moves Flop from 0.26.3 to 0.27.0. `mix.exs` still says `{:flop, "~> 0.20"}`, so the bump comes from the release's `mix.lock`. If you keep your own lock, run `mix deps.update flop`. Two things change in 0.27:
- **Every join field and custom field needs `:ecto_type`.** Any `Flop.Schema` derivation of yours with `join_fields` or `custom_fields` fails until you add an `ecto_type:` to each of them. Pro's two data table settings modules are already fixed.
- **Filters per request are capped at 20 by default** (`max_filters`). Raise it if one of your screens sends more.
#### 2. Layouts.empty is now Layouts.blank
The library now ships `<.empty>`, so Pro's `Layouts.empty/1` is renamed to `Layouts.blank/1`. Any call of yours to `Layouts.empty` breaks. Point it at `blank` instead:
```diff
-{PetalProWeb.Layouts, :empty}
+{PetalProWeb.Layouts, :blank}
```
The template file moves from `lib/petal_pro_web/components/layouts/empty.html.heex` to `blank.html.heex` in the same folder. If you customised it, carry your changes over.
#### 3. Four Pro components are now the free ones
`color_scheme_switch`, `language_select`, `local_time` and `social_button` graduated to petal_components, so Pro deletes its copies. `PetalProComponents` imports the free modules, so `use PetalProComponents` still provides every name. Pro's own call sites are updated in the release. You only need to change calls in your own code. A fully qualified call to an old module, such as `PetalProWeb.ColorSchemeSwitch.color_scheme_switch` or `PetalProWeb.LanguageSelect.language_select`, breaks because the module is gone. Use the plain `<.color_scheme_switch>` / `<.language_select>` tag instead.
If you customised the old Pro copies, keep your fork of those files and skip this step.
**color_scheme_switch**
| Old (Pro) | New (free) | Notes |
|---|---|---|
| `<.color_scheme_switch />` | `<.color_scheme_switch id="theme-switch" />` | `id` is now required |
| `` | `<.color_scheme_script />` | goes in the same place in the head |
```diff
-
+ <.color_scheme_script />
```
Saved preferences survive because the `localStorage.scheme` key is the same. The free switch also tracks the system preference live and stays in sync across tabs.
**local_time**
| Old (Pro) | New (free) | Notes |
|---|---|---|
| no `id` | `id="joined-at"` | `id` is now required (the old one generated a UUID) |
| `for=` | `at=` | `at` is required |
| `preset="DATETIME_MED"` (the old default) | `format="datetime"` (the new default) | |
| other `preset=` values | `format="date"`, `"time"` or a map of `Intl.DateTimeFormat` options | luxon preset names are not accepted |
| `format="relative"` | `format="relative"` | unchanged |
| `format="yyyy mm dd"` (luxon tokens) | a map of `Intl.DateTimeFormat` options | e.g. `format={%{dateStyle: "full"}}` |
| `locale` defaulted to `"en"` | `locale` defaults to the browser's own | pass `locale="en"` to keep the old output |
**social_button**
| Old (Pro) | New (free) | Notes |
|---|---|---|
| `logo=` | `provider=` | |
| `link_type="a" to=` | `href=` | `link_type="live_redirect"` becomes `navigate=`, `"live_patch"` becomes `patch=` |
| `logo="twitter"` | `provider="x"` | the bird is now the X logo |
| `variant` defaulted to `"solid"` | `variant` defaults to `"outline"` | pass `variant="solid"` on any call that relied on the old default |
**language_select** is a straight swap. It takes the same `current_locale`, `language_options` and `current_path` attrs.
Then delete the old component files, the two old JS hooks and the hooks' entries in `assets/js/hooks/index.js` (`ColorSchemeHook` and `LocalTimeHook`):
```
lib/petal_pro_web/components/pro_components/color_scheme_switch.ex
lib/petal_pro_web/components/pro_components/language_select.ex
lib/petal_pro_web/components/pro_components/local_time.ex
lib/petal_pro_web/components/pro_components/social_button.ex
assets/js/hooks/color-scheme-hook.js
assets/js/hooks/local-time-hook.js
```
That leaves `luxon` orphaned in `package.json`. Unless your own code uses it, you can drop it:
```shell
npm uninstall luxon --prefix assets
```
#### 4. Tom Select is gone
Pro's Tom Select wrapper (`PetalProWeb.ComboBox`, the `ComboBoxHook`, `assets/css/combo-box.css` and the `tom-select` npm package) is deleted. The two admin membership pickers and the `petal.gen.live` / `petal.gen.html` generators now render `<.field type="combobox">` from petal_components. It carries its value in a hidden native `