Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Reconcile platform-auth plan status with landed work
Łukasz Adamczyka5bf94e84eba
diff --git a/docs/plans/6.0-platform-auth.md b/docs/plans/6.0-platform-auth.mdindex 0ed145d99f..214e25b11f 100644--- a/docs/plans/6.0-platform-auth.md+++ b/docs/plans/6.0-platform-auth.md@@ -1,10 +1,10 @@# Platform-Owned Authentication & User Model Rename-**Status:** In Progress (RefreshToken shipped in 5.4 ✓; Phases 1–3 implemented — gem-owned `Spree::Customer`/`Spree::AdminUser` models + `Spree.customer_class` rename + `user_id`→`customer_id`; Phase 2 data migration implemented — `spree:upgrade:migrate_users_to_customers` (Path A) + custom-model recipe (Path B); Phase 4 mostly shipped earlier (refresh tokens + endpoints + rate limiting), with account-lockout **enforcement** + config prefs + admin-logout throttle landed; Phase 5 (Devise + legacy models removed, core/api-scoped) + Phase 6 (aliases kept, Devise docs swept) done; `spree/admin` removal, starter 5b, the 6.0 upgrade guide, and `spree_users` teardown deferred)+**Status:** In Progress (RefreshToken shipped in 5.4 ✓; Phases 1–3 implemented — gem-owned `Spree::Customer`/`Spree::AdminUser` models + `Spree.customer_class` rename + `user_id`→`customer_id` (fresh-install migration ordering corrected — two redundant `spree_admin_users` ALTER migrations dropped); Phase 2 data migration implemented — `spree:upgrade:migrate_users_to_customers` (Path A) + custom-model recipe (Path B); Phase 4 mostly shipped earlier (refresh tokens + endpoints + rate limiting), with account-lockout **enforcement** + config prefs + admin-logout throttle landed; Phase 5 (Devise + legacy models removed, core/api-scoped; headless gem-owned `template.rb`) + Phase 6 (aliases kept, Devise docs swept) done; `spree/admin` removal, starter 5b, the 6.0 upgrade guide, and `spree_users` teardown deferred)**Target:** Spree 5.4 (RefreshToken ✓) + Spree 6.0 (Devise removal, User→Customer rename)**Depends on:** Admin SPA (6.0-admin-spa.md — removes Rails admin, kills Devise dependency) for Devise removal**Author:** Damian + Claude-**Last updated:** 2026-07-29+**Last updated:** 2026-07-30## Summary@@ -381,6 +381,7 @@ upgrades). It creates `spree_customers` fresh, and for `spree_admin_users` guard- `Spree::UserMethods` → `Spree::CustomerMethods` (absorbs `UserAddress` + `UserPaymentSource`); constant-alias file keeps the old name. Concern made column-agnostic: password-reset token key falls back through `password_salt` → `encrypted_password` → `password_digest`; `login` write guarded by `has_attribute?`.- FK/association back-compat via a `Spree::DeprecatedCustomerAlias` concern (deprecated `user`/`user_id`/`:user` reader+writer) included on the 10 models; `spree_customer_group_users` is polymorphic so `user_type` → `customer_type` too. Model-scoped i18n error keys added under `spree/customer`.- Historical `add_*_to_spree_users` migrations now guard on `table_exists?(Spree.customer_class.table_name)` so a fresh default install (where the complete `spree_customers` is created by its own migration) skips them cleanly, while a custom user table still gets backfilled.+- The two historical `spree_admin_users` ALTER migrations (`add_first_and_last_name_to_spree_admin_class`, `add_selected_locale_to_spree_admin_users`) were **removed**: unlike the `spree_users` ALTERs they carried no `table_exists?` guard, so on a fresh gem-owned install — where nothing creates `spree_admin_users` before them — they aborted `db:migrate`. Their columns already ship in `create_spree_customers_and_admin_users` and the dummy generator, and existing installs ran them long ago.- `spree/admin` left untouched (removed in 6.0) — it rides the deprecated `Spree.user_class` alias.- **Spree's own specs use `customer` directly, not the aliases** (aliases are only to smooth external-gem migration): factory calls migrated `user:` → `customer:` for renamed-model factories (Import/Export/Report/RoleUser/RefreshToken/StateChange/UserIdentity keep `user:`), `Spree.user_class` → `Spree.customer_class`. Core `spec/models` + `spec/services` + `spec/lib` are green (7094 examples). Remaining: first-party code `.user`/`.user_id` *reads* still on aliases (functional, warn-only) + `spree/api` & `spree/emails` spec migration/runs.@@ -403,6 +404,7 @@ Landed:(included by both models) reading `Spree::Config[:max_failed_login_attempts]` (5) and`[:lockout_duration]` (1800s) instead of the previously hardcoded `5` / `30.minutes`.- **Admin logout rate-limit** added to match the store side.+- **Dashboard login surfaces the server message** (`@spree/dashboard` `login.tsx`) so the lockout response reaches the UI instead of a generic error — bad credentials and lockout share an error code, so the message is the only distinguishing signal.Not pursued: hashing refresh tokens at rest (they're already random + expiring, and login israte-limited).@@ -415,6 +417,7 @@ Landed (scoped to `spree/core` + `spree/api`):- Removed the Devise bridges — `Spree::AdminUserMethods::DeviseNotifications` and `CustomerMethods::SkipPasswordValidation` — plus their spec/controller callers. Live admin auth emails already flow through the `admin_user.password_reset_requested` event subscriber; password-less admin-created customers work via `has_secure_password validations: false`.- Removed the core `devise:` i18n block and reworded the Devise comments.- Flipped the root-gem `spree:install` `--authentication` default to `nil` (a plain install scaffolds no auth — the gem owns it) and dropped the devise dispatch branch; removed the `common_rake` devise shell-out.+- Rewrote the documented `rails new -m template.rb` install to be headless and gem-owned: drops the `devise` and `spree_admin` gems, installs core + API only (no `--authentication`/`--user_class` flags), and removes the obsolete `Procfile.dev` step (`bin/dev` runs the server directly). `USE_LOCAL_SPREE` now takes a monorepo path so the template resolves edge gems. (The spree-starter clone behind `create-spree-app`/`server:setup` is still Devise — that is Phase 5b.)Deferred (NOT done here):- `spree/admin`'s Devise controllers/generators (`user_sessions_controller`, `user_passwords_controller`, `spree/admin/devise/`) ride the wholesale admin-gem removal (`6.0-admin-spa.md`).