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
Drop orphaned confirmation email, sweep Devise mentions + docs (platform-auth Phase 6)
Łukasz Adamczykca7f6151b54a
diff --git a/.claude/settings.local.json b/.claude/settings.local.jsonindex 49a8f344d6..67770f98f9 100644--- a/.claude/settings.local.json+++ b/.claude/settings.local.json@@ -38,8 +38,10 @@"Read(**/.env)","Read(**/.env.*)","Read(**/secrets/*)",- "Read(**/*credential*)",- "Read(**/*password*)",+ "Read(**/credentials.yml.enc)",+ "Read(**/config/credentials/**)",+ "Read(**/.pgpass)",+ "Read(**/.htpasswd)","Edit(~/.ssh/*)","Edit(~/.gnupg/*)","Edit(~/.aws/*)",diff --git a/docs/developer/admin/admin.mdx b/docs/developer/admin/admin.mdxindex 0dfec62954..f088d686fb 100644--- a/docs/developer/admin/admin.mdx+++ b/docs/developer/admin/admin.mdx@@ -201,7 +201,7 @@ bin/rails g controller Spree::Admin::Brands --skip-routesAdmin users must be authenticated to access the dashboard. Spree supports:-- Built-in Devise authentication+- Built-in `has_secure_password` authentication (the gem-owned `Spree::AdminUser` model)- Custom authentication adapters- SSO integrationdiff --git a/docs/developer/admin/authentication.mdx b/docs/developer/admin/authentication.mdxindex da3f518cb1..e558d7d619 100644--- a/docs/developer/admin/authentication.mdx+++ b/docs/developer/admin/authentication.mdx@@ -1,59 +1,32 @@---title: Admin Panel AuthenticationsidebarTitle: Authentication-description: How to customize the Spree admin panel authentication+description: How to customize authentication for the Spree admin----Spree allows you to use a different model for the admin panel than the storefront (that's the default since Spree 5.2).-Here you can find how to customize the admin panel authentication to use a different model.+Spree uses a separate model for admin/staff accounts (`Spree::AdminUser`) from storefront customers (`Spree::Customer`) — the default since Spree 5.2. Both are gem-owned and backed by [`has_secure_password`](https://api.rubyonrails.org/classes/ActiveModel/SecurePassword/ClassMethods.html); the admin dashboard authenticates against the Admin API with JWT access + refresh tokens, so no setup is required for the default.-Let's assume you have an existing `AdminUser` model in your application and you're using Devise for authentication.+You only need the steps below if you want the admin to authenticate against your **own** admin model.-In `config/initializers/spree.rb` file, add the following line:+## Using your own admin model-```ruby-Spree.admin_user_class = 'AdminUser'-```--This will tell Spree to use your `AdminUser` model for the admin panel. You will also need to add the following line in that model file:+Point `Spree.admin_user_class` at your model in `config/initializers/spree.rb`:```ruby-include Spree::UserMethods+Spree.admin_user_class = 'MyApp::AdminUser'```-In your `config/initializers/routes.rb` file, you will need to define devise routes for the 2nd model:+On that model, include the admin concern (roles, permissions, store access) and add `has_secure_password`:```ruby-Spree::Core::Engine.routes.prepend_routes do- # Admin authentication- devise_for(- Spree.admin_user_class.model_name.singular_route_key,- class_name: Spree.admin_user_class.to_s,- controllers: {- sessions: 'spree/admin/user_sessions',- passwords: 'spree/admin/user_passwords'- },- skip: :registrations,- path: :admin_user,- router_name: :spree- )-end-```--And now in your `lib/spree/authentication_helpers.rb` file, please replace the following lines:+# app/models/my_app/admin_user.rb+class MyApp::AdminUser < ApplicationRecord+ has_secure_password validations: false-```diff- def spree_admin_login_path(opts = {})-- spree_login_path(opts)-+ new_admin_user_session_path(opts)- end-- def spree_admin_logout_path(opts = {})-- spree_logout_path(opts)-+ destroy_admin_user_session_path(opts)- end+ include Spree::AdminUserMethods+end```-Now when attempting to access the admin panel, you will be redirected to the dedicated admin panel login page.+If the model keeps an existing password column (for example `encrypted_password`), bridge it as described in [Authentication](/developer/customization/authentication#keeping-an-existing-password-column).-\ No newline at end of file+The admin dashboard signs in through the Admin API auth endpoints (`POST /api/v3/admin/auth/login`, plus `refresh` and `logout`); custom providers plug in via `Spree.admin_authentication_strategies` (see [Custom authentication providers](/developer/customization/authentication#custom-authentication-providers)).diff --git a/docs/developer/admin/extending-ui.mdx b/docs/developer/admin/extending-ui.mdxindex a2a8923049..303a33e90f 100644--- a/docs/developer/admin/extending-ui.mdx+++ b/docs/developer/admin/extending-ui.mdx@@ -431,7 +431,7 @@ Here's a list of all places you can inject your custom code:#### Variables- <ParamField path="user" type="Spree.user_class">+ <ParamField path="user" type="Spree.customer_class">The customer displayed on the page.</ParamField>diff --git a/docs/developer/admin/tables.mdx b/docs/developer/admin/tables.mdxindex 92b3252035..5af38da200 100644--- a/docs/developer/admin/tables.mdx+++ b/docs/developer/admin/tables.mdx@@ -501,7 +501,7 @@ Spree registers tables for all built-in resources:| `:products` | `Spree::Product` || `:orders` | `Spree::Order` || `:checkouts` | `Spree::Order` (draft) |-| `:users` | `Spree.user_class` |+| `:users` | `Spree.customer_class` || `:promotions` | `Spree::Promotion` || `:customer_returns` | `Spree::CustomerReturn` || `:option_types` | `Spree::OptionType` |diff --git a/docs/developer/advanced/adding_spree_to_rails_app.mdx b/docs/developer/advanced/adding_spree_to_rails_app.mdxindex 50a9d17b17..198578994a 100644--- a/docs/developer/advanced/adding_spree_to_rails_app.mdx+++ b/docs/developer/advanced/adding_spree_to_rails_app.mdx@@ -38,19 +38,20 @@ Spree uses a modular installation approach. First install the core, then add opt### Install core Spree-This installs core models, API, CLI, and authentication:+This installs core models, API, CLI, and the gem-owned authentication models (`Spree::Customer` and `Spree::AdminUser`):```bash-bin/rails g spree:install --user_class=Spree::User --authentication=devise+bin/rails g spree:install```+To authenticate against your own user model instead of the defaults, pass `--user_class` (see [Authentication](/developer/customization/authentication)).+**Core installation options:**| Option | Description ||--------|-------------|-| `user_class` | The class for your users, eg. `Spree::User` or `User` |-| `admin_user_class` | The class for admin users (defaults to `user_class`) |-| `authentication` | Authentication gem: `devise` or `custom` |+| `user_class` | The customer model class (default: `Spree::Customer`) |+| `admin_user_class` | The admin model class (default: `Spree::AdminUser`) || `migrate` | Whether to run migrations (default: true) || `seed` | Whether to run the seed file (default: true) || `sample` | Whether to add sample data (default: false) |@@ -61,7 +62,6 @@ bin/rails g spree:install --user_class=Spree::User --authentication=devise```bashbin/rails g spree:admin:install-bin/rails g spree:admin:devise # if using Devise authentication```### Add sample data (optional)diff --git a/docs/developer/core-concepts/events.mdx b/docs/developer/core-concepts/events.mdxindex cb06b4b4d3..a02d777ead 100644--- a/docs/developer/core-concepts/events.mdx+++ b/docs/developer/core-concepts/events.mdx@@ -256,7 +256,7 @@ Models with lifecycle events enabled include: `Order`, `Payment`, `Price`, `Ship| `user.updated` | User was updated || `user.deleted` | User was deleted |-When `Spree.admin_user_class` differs from `Spree.user_class`, admin users publish the equivalent `admin.*` events (see the Admin Events table below).+When `Spree.admin_user_class` differs from `Spree.customer_class`, admin users publish the equivalent `admin.*` events (see the Admin Events table below).### Admin Eventsdiff --git a/docs/developer/core-concepts/imports-exports.mdx b/docs/developer/core-concepts/imports-exports.mdxindex 2c9d83454f..e0f8775ffa 100644--- a/docs/developer/core-concepts/imports-exports.mdx+++ b/docs/developer/core-concepts/imports-exports.mdx@@ -472,7 +472,7 @@ module Spreedef find_or_create_useremail = attributes['email'].strip.downcase- Spree.user_class.find_or_create_by!(email: email)+ Spree.customer_class.find_or_create_by!(email: email)enddef find_plandiff --git a/docs/developer/core-concepts/users.mdx b/docs/developer/core-concepts/users.mdxindex 05a6ec8d24..20c4bd1825 100644--- a/docs/developer/core-concepts/users.mdx+++ b/docs/developer/core-concepts/users.mdx@@ -1,6 +1,6 @@---title: Users-description: How Spree models customer and admin users — Devise authentication, account data, roles, abilities, and access permissions across stores.+description: How Spree models customer and admin users — account data, roles, abilities, and access permissions across stores.---## Overview@@ -12,11 +12,11 @@ Spree has two separate user types:| User type | Class | Default ||-----------|-------|---------|-| Customers | `Spree.user_class` | `Spree::User` |+| Customers | `Spree.customer_class` | `Spree::Customer` || Admins | `Spree.admin_user_class` | `Spree::AdminUser` |<Info>-You can use your own user classes. See the [Customize Authentication guide](/developer/customization/authentication) for details.+You can use your own user classes. See the [Customize Authentication guide](/developer/customization/authentication) for details. `Spree.user_class` still works as a deprecated alias for `Spree.customer_class` and will be removed in Spree 6.1.</Info>## Customersdiff --git a/docs/developer/customization/authentication.mdx b/docs/developer/customization/authentication.mdxindex ae7bb11d99..b60f79eebd 100644--- a/docs/developer/customization/authentication.mdx+++ b/docs/developer/customization/authentication.mdx@@ -1,103 +1,54 @@---title: Authentication-description: Integrate Spree with a custom authentication setup, including Devise, an existing user model, OmniAuth providers, and JWT or OAuth API tokens.+description: How Spree authenticates customers and admins, and how to plug in your own user model or authentication provider.version: v5----If you installed Spree following the [Quickstart guide](/developer/quickstart), you can completely skip this step - you are all set and integrated with the [Devise](https://github.com/plataformatec/devise) gem.+Spree ships with built-in, gem-owned authentication models — `Spree::Customer` (storefront customers) and `Spree::AdminUser` (staff) — backed by Rails' [`has_secure_password`](https://api.rubyonrails.org/classes/ActiveModel/SecurePassword/ClassMethods.html). If you installed Spree following the [Quickstart guide](/developer/quickstart), authentication is already set up and you can skip this page.-However if you're adding Spree to an existing application that has its own authentication system, you will need to follow these steps.+You only need the steps below if you want Spree to authenticate against your **own** user model — for example a shared/SSO user table, or an existing application you're adding Spree to.-## Using Devise+## Using your own user model-If you're currently using [Devise](https://github.com/plataformatec/devise) for authentication, you can follow the steps below to integrate Spree with your existing authentication system.--Firstly set your `User` class as `Spree.user_class` in your `config/initializers/spree.rb` file:+Point `Spree.customer_class` (and optionally `Spree.admin_user_class`) at your model in `config/initializers/spree.rb`:```ruby-Spree.user_class = 'User'-```--Now, run the generator to set up Spree integration with Devise:--<CodeGroup>--```bash Spree CLI (Docker)-spree generate spree:authentication:devise-```--```bash Without Spree CLI-bin/rails g spree:authentication:devise+Spree.customer_class = 'MyApp::User'```-</CodeGroup>+> `Spree.user_class` still works as a deprecated alias for `Spree.customer_class` and will be removed in Spree 6.1.-This will create a new file in `lib/spree/authentication_helpers.rb` that serves as a bridge between Spree and your existing authentication system routes. You can then use this file to customize the routes to your liking. It should automatically pick up standard Devise routes.--Secondly, this generator will add necessary modules to your `User` model.+On that model, include the Spree customer concern — a single include that brings in addresses, payment sources, orders, wishlists, and store credit — and add `has_secure_password`:```ruby-# app/models/user.rb-class User < ApplicationRecord- # ... your existing code ...+# app/models/my_app/user.rb+class MyApp::User < ApplicationRecord+ has_secure_password validations: false- include Spree::UserAddress- include Spree::UserMethods- include Spree::UserPaymentSource+ include Spree::CustomerMethodsend```-This will ensure that your `User` model can be used as a Spree user.--This generator will also add 2 new lines to your Spree initializer file:--```ruby-Devise.parent_controller = "Spree::BaseController"-Devise.parent_mailer = "Spree::BaseMailer"-```--This ensures that Devise will use Spree storefront layout for login/signup/etc and use Spree mailer layout for sending emails so they'll match your Storefront branding.+`Spree::CustomerMethods` absorbs the former `Spree::UserAddress` and `Spree::UserPaymentSource` concerns, so this single include is all that's required.-If you have more complex setup, you can remove these lines and customize the routes and mailer in your own initializer file.+### Keeping an existing password column-## Using Custom Authentication--If you're using a custom authentication system, you can follow the steps below to integrate Spree with your existing authentication system.--Firstly set your `User` class as `Spree.user_class` in your `config/initializers/spree.rb` file:+If your model already stores its password digest in a column other than `password_digest` — for example the `encrypted_password` column from a Devise-based app — bridge it so `has_secure_password` can read it. Either alias the column:```ruby-Spree.user_class = 'User'-```--Now, run the generator to set up Spree integration with your custom authentication system:--<CodeGroup>--```bash Spree CLI (Docker)-spree generate spree:authentication:custom-```+class MyApp::User < ApplicationRecord+ has_secure_password validations: false+ include Spree::CustomerMethods-```bash Without Spree CLI-bin/rails g spree:authentication:custom+ alias_attribute :password_digest, :encrypted_password+end```-</CodeGroup>--This will create a new file in `lib/spree/authentication_helpers.rb` that serves as a bridge between Spree and your existing authentication system routes. You will need to customize this file to fit your needs.--Secondly, this generator will add necessary modules to your `User` model.+or rename the column to `password_digest` in a migration. A plain bcrypt digest (such as Devise's `encrypted_password` with no pepper configured) is read directly by `has_secure_password`, so existing passwords keep working with no reset.-```ruby-# app/models/user.rb-class User < ApplicationRecord- # ... your existing code ...+## Custom authentication providers- include Spree::UserAddress- include Spree::UserMethods- include Spree::UserPaymentSource-end-```+Spree authenticates through pluggable strategies — `Spree.store_authentication_strategies` and `Spree.admin_authentication_strategies` — which default to email + password. To plug in an external provider (Auth0, Clerk, SSO, and so on), implement a `Spree::Authentication::Strategies::BaseStrategy` subclass and register it. See [Custom API authentication](/developer/how-to/custom-api-authentication) for a worked example.## Admin Panel authenticationdiff --git a/docs/developer/customization/permissions.mdx b/docs/developer/customization/permissions.mdxindex 0b85f53590..e08cef551a 100644--- a/docs/developer/customization/permissions.mdx+++ b/docs/developer/customization/permissions.mdx@@ -159,7 +159,7 @@ Spree::Role.find_or_create_by(name: 'warehouse_staff')Assign a role to a user:```ruby-user = Spree.user_class.find_by(email: '[email protected]')+user = Spree.customer_class.find_by(email: '[email protected]')role = Spree::Role.find_by(name: 'customer_service')user.spree_roles << role```@@ -221,7 +221,7 @@ class CustomAbility < Spree::Abilitydef initialize(user, options = {})alias_cancan_delete_action- @user = user || Spree.user_class.new+ @user = user || Spree.customer_class.new@store = options[:store] || Spree::Current.storeif @user.respond_to?(:has_spree_role?) && @user.has_spree_role?('admin')@@ -239,7 +239,7 @@ class CustomAbility < Spree::Abilitydef apply_customer_service_permissions(user)can :manage, Spree::Order- can [:read, :admin], Spree.user_class+ can [:read, :admin], Spree.customer_classendend```diff --git a/docs/developer/customization/quickstart.mdx b/docs/developer/customization/quickstart.mdxindex d23da7806a..05e4646f41 100644--- a/docs/developer/customization/quickstart.mdx+++ b/docs/developer/customization/quickstart.mdx@@ -149,7 +149,7 @@ Spree is a flexible platform allowing you to customize every part of it to suit<Accordion title="Authentication">**Best for:** Using your own user model or authentication system.- Spree allows you to use your own authentication system instead of the default Devise-based one.+ Spree ships gem-owned `has_secure_password` models by default, and lets you point it at your own user model or authentication provider instead.You can find more information in the [Authentication](authentication) section.</Accordion>diff --git a/docs/developer/how-to/custom-api-authentication.mdx b/docs/developer/how-to/custom-api-authentication.mdxindex 3f7c188bf4..9de0c7aa54 100644--- a/docs/developer/how-to/custom-api-authentication.mdx+++ b/docs/developer/how-to/custom-api-authentication.mdx@@ -25,7 +25,7 @@ The mechanism is identical for both surfaces. A strategy you write works on eith| | Store API (customers) | Admin API (staff) ||---|---|---|| Registry | `Spree.store_authentication_strategies` | `Spree.admin_authentication_strategies` |-| User class | `Spree.user_class` | `Spree.admin_user_class` |+| User class | `Spree.customer_class` | `Spree.admin_user_class` || Login endpoint | `POST /api/v3/store/auth/login` | `POST /api/v3/admin/auth/login` || Refresh endpoint | `POST /api/v3/store/auth/refresh` | `POST /api/v3/admin/auth/refresh` || JWT audience | `aud: store_api` | `aud: admin_api` |@@ -136,7 +136,7 @@ end|---|---|| `success(user)` | Wrap a user in a successful `ServiceModule::Result` || `failure(message)` | Wrap an error message in a failed result |-| `find_user_by_email(email)` | Lookup against `Spree.user_class` |+| `find_user_by_email(email)` | Lookup against `Spree.customer_class` || `find_or_create_user_from_oauth(provider:, uid:, info:, tokens: {})` | Calls `Spree::UserIdentity.find_or_create_from_oauth` with the right `user_class` || `params`, `request_env`, `user_class` | Reader access to the controller-supplied inputs |@@ -181,7 +181,7 @@ Both registries are a `Spree::Authentication::StrategyRegistry` with the same AP| `[key]` | Look up a registered class. || `key?(key)`, `keys`, `values`, `each`, `to_h` | Standard introspection. |-The strategy is instantiated with the surface's user class automatically — `Spree.user_class` from the store registry, `Spree.admin_user_class` from the admin registry — and your `authenticate` reads it via the `user_class` helper, so the same class provisions customers on one side and staff on the other.+The strategy is instantiated with the surface's user class automatically — `Spree.customer_class` from the store registry, `Spree.admin_user_class` from the admin registry — and your `authenticate` reads it via the `user_class` helper, so the same class provisions customers on one side and staff on the other.<Tip>Restrict a surface to SSO by removing the built-in email/password strategy after adding yours: `Spree.admin_authentication_strategies.remove(:email)` locks staff to your provider; the store side stays on email/password.@@ -370,14 +370,14 @@ RSpec.describe MyApp::Auth::ExternalJwtStrategy doendit 'provisions a Spree user on first login' do- expect { result }.to change(Spree.user_class, :count).by(1)+ expect { result }.to change(Spree.customer_class, :count).by(1)expect(result).to be_successexpect(result.value.email).to eq('[email protected]')endit 'reuses the user on subsequent logins' dodescribed_class.new(params: { token: token }, request_env: {}).authenticate- expect { result }.not_to change(Spree.user_class, :count)+ expect { result }.not_to change(Spree.customer_class, :count)endit 'fails on an expired token' do@@ -395,4 +395,4 @@ end- `Spree::Api::V3::Store::AuthController` — `spree/api/app/controllers/spree/api/v3/store/auth_controller.rb`- `Spree::Api::V3::Admin::AuthController` — `spree/api/app/controllers/spree/api/v3/admin/auth_controller.rb`- `Spree::Api::V3::JwtAuthentication` — `spree/api/app/controllers/concerns/spree/api/v3/jwt_authentication.rb`-- See also: [Staff & Roles](/developer/core-concepts/staff-roles) for the admin login flow, [Customers](/developer/core-concepts/customers) for storefront auth, and [Authentication](/developer/customization/authentication) for `Spree.user_class` integration.+- See also: [Staff & Roles](/developer/core-concepts/staff-roles) for the admin login flow, [Customers](/developer/core-concepts/customers) for storefront auth, and [Authentication](/developer/customization/authentication) for `Spree.customer_class` integration.diff --git a/docs/developer/storefront/rails/helper-methods.mdx b/docs/developer/storefront/rails/helper-methods.mdxindex ef02567a83..5ca3117fcd 100644--- a/docs/developer/storefront/rails/helper-methods.mdx+++ b/docs/developer/storefront/rails/helper-methods.mdx@@ -50,11 +50,11 @@ Returns the current order object. If no order is found, it will return `nil`.### `try_spree_current_user`-<ResponseField name="try_spree_current_user" type="Spree.user_class" description="The current user object.">+<ResponseField name="try_spree_current_user" type="Spree.customer_class" description="The current user object."><SpreeUser /></ResponseField>-Returns the current user object (class depends on the `Spree.user_class` configuration). If the user is not signed in, it will return `nil`.+Returns the current user object (class depends on the `Spree.customer_class` configuration). If the user is not signed in, it will return `nil`.<Tip>If you want to check if the user is signed in, you can use the following:diff --git a/docs/plans/6.0-platform-auth.md b/docs/plans/6.0-platform-auth.mdindex 2c1fd99c16..0ed145d99f 100644--- a/docs/plans/6.0-platform-auth.md+++ b/docs/plans/6.0-platform-auth.md@@ -1,6 +1,6 @@# Platform-Owned Authentication & User Model Rename-**Status:** In Progress (RefreshToken shipped in 5.4 ✓; Phases 1–3 implemented on `feature/v-3514` — 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); Phases 4–6 pending)+**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)**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@@ -325,7 +325,7 @@ class CreateSpreeCustomersAndAdminUsers < ActiveRecord::Migration[7.2]end```-### Phase 2: Data migration (for existing Devise-based installs) — implemented on `feature/v-3514`+### Phase 2: Data migration (for existing Devise-based installs) — implementedTwo supported paths, both delivered:@@ -375,7 +375,7 @@ upgrades). It creates `spree_customers` fresh, and for `spree_admin_users` guard- Rename `user_id` FK → `customer_id` on 11 customer-facing tables (see decisions.md entry)- Update `belongs_to :user` → `belongs_to :customer` on those models-**Implementation notes (Phases 1 & 3, `feature/v-3514`):**+**Implementation notes (Phases 1 & 3):**- `Spree::Customer` (new `spree_customers`, complete column set) + `Spree::AdminUser` (existing `spree_admin_users` + `password_digest`) both use `has_secure_password validations: false` with a confirmation-only validation — password presence is **not** enforced at the model level (matches the prior LegacyUser default; storefront registration / admin-claim own that), so admin-created password-less accounts stay valid. `valid_password?` kept as an `authenticate` alias.- Prefix IDs: `cust_` (was `cus`) / `adm_` (was `admin`).- `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?`.@@ -384,24 +384,41 @@ upgrades). It creates `spree_customers` fresh, and for `spree_admin_users` guard- `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.-### Phase 4: Refresh token support--- Create `Spree::RefreshToken` model-- Update `AuthController` to issue refresh tokens alongside access JWTs-- Add `POST /auth/refresh` and `POST /auth/logout` endpoints-- Add rate limiting to auth endpoints-- Add account lockout to Customer/AdminUser--### Phase 5: Remove Devise + all authentication generators--- Delete `spree/core/lib/generators/spree/authentication/devise/` directory-- Delete `spree/core/lib/generators/spree/authentication/custom/` directory-- Delete `spree/admin/lib/generators/spree/admin/devise/` directory-- Delete `spree/admin/app/controllers/spree/admin/user_sessions_controller.rb`-- Delete `spree/admin/app/controllers/spree/admin/user_passwords_controller.rb`-- Remove all `defined?(Devise::...)` conditional checks-- Remove Warden references from controller helpers-- Delete `Spree::LegacyUser` and `Spree::LegacyAdminUser`+### Phase 4: Refresh tokens, rate limiting, account lockout++Shipped earlier (5.4 + prior 6.0 work):+- `Spree::RefreshToken` model (issue/rotate/revoke) — `create_for` / `rotate!` / `revoke_all_for`.+- `AuthController` issues refresh tokens alongside access JWTs, and `POST /auth/refresh` ++ `POST /auth/logout` for both store (refresh token in body) and admin (HttpOnly cookie).+- Rate limiting (Rails `rate_limit`) on login/refresh/register/password-reset + per-publishable-key+ throttle + `X-RateLimit-*` headers, all config-driven via `Spree::Api::Config[:rate_limit_*]`.+- Account-lockout **methods** + `failed_attempts`/`locked_at` columns on Customer/AdminUser.++Landed:+- **Account-lockout enforcement.** `EmailPasswordStrategy#authenticate` now blocks locked accounts+ (distinct "temporarily locked" message), records a failed attempt on a bad password, and resets on+ success — `respond_to?`-guarded so a custom `customer_class` without lockout still authenticates.+ One hook covers both store and admin login.+- **Config-driven thresholds.** Lockout logic extracted into a shared `Spree::AccountLockout` concern+ (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.++Not pursued: hashing refresh tokens at rest (they're already random + expiring, and login is+rate-limited).++### Phase 5: Remove Devise + all authentication generators — core/api done++Landed (scoped to `spree/core` + `spree/api`):+- Deleted the `spree/core/lib/generators/spree/authentication/devise/` and `custom/` generators (kept `dummy/` for the test harness).+- Deleted `Spree::LegacyUser` and `Spree::LegacyAdminUser` (4 specs repointed to `Spree.customer_class`).+- 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.++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`).+- The `defined?(Devise)` guards in `spree:upgrade:migrate_users_to_customers` are **kept** (defensive for installs migrating off Devise). No Warden references existed in core/api.### Phase 5b: spree-starter changes@@ -413,11 +430,21 @@ The starter currently ships the host-app auth code the generator produced. At 6.- Remove `devise_for` routes and the `Devise.parent_controller` initializer block- Ship the Path A migration rake task invocation in the upgrade guide-### Phase 6: Cleanup (still 6.0)+### Phase 6: Cleanup (still 6.0) — partially done++- **Deprecation aliases kept through 6.0** (revised): `Spree.user_class`/`user_class=`, `Spree::UserMethods`, `Spree::DeprecatedCustomerAlias`, and the `:user` factory alias all remain for 6.0. This supersedes the earlier "remove the `user_class` alias in 6.0" plan; their removal is extracted to Phase 7 (6.1).+- `Spree::OauthAccessToken`: nothing remains (extracted upstream to `legacy_api_v2`). No-op. ✓+- **Devise / `user_class` docs sweep — done**: rewrote the Devise-as-default pages (customization/authentication, admin/authentication, adding_spree_to_rails_app, customization/quickstart, admin.mdx) around the gem-owned `Spree::Customer`/`AdminUser` + `has_secure_password` + custom-model recipe, and swept `Spree.user_class` → `Spree.customer_class` across the incidental docs (kept the alias notes + historical upgrade guides). The multi-tenant quickstart's Devise example was left intact (it targets a Devise-based custom model) with a clarifying note.+- Deferred: the net-new `docs/developer/upgrades/5.6-to-6.0.mdx` (with the Path A/B migrate-users section), the `spree_users` table teardown task, and the search-area `multi_search` alias removal.++### Phase 7: Remove deprecation aliases (6.1)++Breaking cleanup for 6.1 — remove the compatibility shims kept through 6.0 (all tagged "remove in Spree 6.1" in code), after sweeping any remaining first-party callers off them:-- Remove deprecation alias for `user_class` (keep only `customer_class`)-- Remove `Spree::OauthAccessToken` if any references remain-- Update all docs referencing Devise+- `Spree.user_class` / `Spree.user_class=` shims in `spree/core/lib/spree/core.rb` (callers move to `Spree.customer_class`).+- `Spree::UserMethods = CustomerMethods` alias (`spree/core/app/models/concerns/spree/user_methods.rb`).+- `Spree::DeprecatedCustomerAlias` — the deprecated `user` / `user_id` readers + writers — from the 10 customer-facing models.+- The `:user` alias on the `:customer` factory (`spree/core/lib/spree/testing_support/factories/user_factory.rb`).## Constraints on Current Workdiff --git a/docs/plans/decisions.md b/docs/plans/decisions.mdindex 4405f101e9..dc7b688657 100644--- a/docs/plans/decisions.md+++ b/docs/plans/decisions.md@@ -456,3 +456,71 @@ The 5.6→6.0 upgrade guide (`docs/developer/upgrades/5.6-to-6.0.mdx`) doesn't eyet (6.0 in-dev); Path A/B developer guidance currently lives in the task's `desc`,the `5_6_to_6_0` manifest notes, and this plan. It moves to the mdx when the full6.0 upgrade guide is authored.++## 2026-07-29: Account lockout enforced in the auth strategy; thresholds config-driven++Phase 4 of `6.0-platform-auth.md` was mostly already shipped (RefreshToken issue/rotate/revoke,+login/refresh/logout endpoints, Rails `rate_limit` throttling). The remaining gap was that the+lockout methods on Customer/AdminUser were **dead code** — nothing in the login path called them.++Decisions made wiring it up:++**Enforcement lives in `EmailPasswordStrategy`, not the controllers.** The strategy is the single+point both store and admin login flow through, and it's the only layer that holds the user object on+a *failed* password (the controllers get a generic failure). So `authenticate` checks `locked?`+before validating, `record_failed_attempt!` on a bad password, and `reset_failed_attempts!` on+success. All calls are `respond_to?`-guarded so a Path-B custom `customer_class` without the lockout+methods still authenticates.++**Thresholds moved to `Spree::Config`, logic to a shared concern.** The identical+`locked?`/`record_failed_attempt!`/`reset_failed_attempts!` on both models (with hardcoded `5` /+`30.minutes`) were extracted into `Spree::AccountLockout` (core concern) reading+`Spree::Config[:max_failed_login_attempts]` (5) and `[:lockout_duration]` (1800s). These are **core**+prefs (not `Spree::Api::Config`) because the concern lives on core models, which can't depend on the+API config.++**Distinct lockout message** ("Account temporarily locked. Try again later.") over a generic+invalid-credentials response — industry-common, and login is already rate-limited so the marginal+enumeration signal is low. It's a single return string, easily switched to the generic message if a+stricter anti-enumeration posture is wanted (Spree's login/password-reset are otherwise+anti-enumeration).++**Refresh-token hashing at rest was declined** (tokens are already random + expiring; login+throttled). **Admin `logout` gained a `rate_limit`** to match the store side. Following the repo's+rate-limit spec convention, no throttle-*trip* test was added (those depend on the test cache store);+the existing specs cover response format/headers/config.++## 2026-07-29: Devise fully removed from core/api; legacy models deleted, table kept++Phases 5 & 6 of `6.0-platform-auth.md`, scoped to `spree/core` + `spree/api` (spree/admin removed+wholesale by `6.0-admin-spa.md`; the spree-starter / 5b changes are a separate pass).++**Legacy models deleted, `spree_users` table retained.** `Spree::LegacyUser` /+`Spree::LegacyAdminUser` are gone (no runtime fallback — `Spree.customer_class` has no default,+`Role` is dynamic, and only four specs named the constant, all repointed to `Spree.customer_class`).+The `spree_users` **table** is deliberately kept as the Phase 2 migration's safety net — its teardown+is a separate later operator task, and the 4.3 baseline migration still materializes it on fresh+installs.++**Devise bridges removed, not kept.** Both `Spree::AdminUserMethods::DeviseNotifications` and+`CustomerMethods::SkipPasswordValidation` were deleted. They were inert on the gem's+`has_secure_password` models: admin auth emails flow through the `admin_user.password_reset_requested`+event subscriber → `AdminUserMailer` (not `send_devise_notification`), and password-less+admin-created customers rely on `has_secure_password validations: false` rather than a+`password_required?` override. The `defined?(Devise)` guards in the migrate-users rake task are the+one Devise reference kept — they're defensive checks for installs migrating *off* Devise.++**`spree:install` scaffolds no auth by default.** With the generators deleted, the root-gem install+generator's `--authentication` default moved to `nil` (was `devise`): a plain install writes no auth+helpers because the gem owns auth (`Spree::Customer`/`Spree::AdminUser` + the initializer sets the+class names). `dummy` stays available and is what the test harness passes explicitly via+`common_rake`, so `test_app` is unaffected.++**Deprecation aliases kept to 6.1.** The earlier Phase 6 plan to drop the `user_class` alias in 6.0+is superseded — `Spree.user_class`, `Spree::UserMethods`, `Spree::DeprecatedCustomerAlias`, and the+`:user`/`:admin_user` factory aliases all remain through 6.0 (in-code comments already tag them 6.1).++**Docs.** The Devise-as-default pages were rewritten around gem-owned auth + the custom-model recipe,+and `Spree.user_class` references swept to `Spree.customer_class`. `Spree::OauthAccessToken` is a+no-op (extracted upstream). Deferred: the 6.0 upgrade guide, the `spree_users` teardown task, and the+unrelated search-area `multi_search` alias removal.diff --git a/spree/core/app/mailers/spree/admin_user_mailer.rb b/spree/core/app/mailers/spree/admin_user_mailer.rbindex bba7da933b..849d8e1543 100644--- a/spree/core/app/mailers/spree/admin_user_mailer.rb+++ b/spree/core/app/mailers/spree/admin_user_mailer.rb@@ -1,7 +1,7 @@module Spree- # Auth emails for admin users. Reached two ways: the legacy Rails admin's- # Devise flow (via Spree::AdminUserMethods::DeviseNotifications) and the Admin- # API's `admin_user.password_reset_requested` event (dashboard SPA).+ # Auth emails for admin users. Reached via the Admin API's+ # `admin_user.password_reset_requested` event (dashboard SPA), delivered by+ # Spree::AdminUserEmailSubscriber.class AdminUserMailer < BaseMailerdef password_reset_email(admin_user, token, store, redirect_url: nil)@user = admin_user@@ -17,20 +17,6 @@ module Spreeendend- def confirmation_email(admin_user, token, store)- @user = admin_user- @current_store = store- @confirmation_url = confirmation_url(token, store)-- with_store_locale(store, preferred_locale(admin_user, store)) do- mail(- to: admin_user.email,- subject: "#{store.name} #{Spree.t('admin_user_mailer.confirmation_email.subject')}",- store_url: store.formatted_url- )- end- end-private# Locale chain for admin auth emails:@@ -47,25 +33,10 @@ module Spreelocale.present? && I18n.available_locales.map(&:to_s).include?(locale.to_s)end- # The dashboard SPA passes a validated redirect URL (token appended as a- # query param); the legacy Devise flow links to its own edit-password route- # when the host app installed it.+ # The dashboard SPA passes a validated redirect URL; the token is appended as+ # a query param, falling back to the store URL.def password_reset_url(token, store, redirect_url)- return append_token(redirect_url, token) if redirect_url.present?-- if spree.respond_to?(:edit_admin_user_password_url)- spree.edit_admin_user_password_url(reset_password_token: token, host: store.formatted_url)- else- append_token(store.formatted_url, token)- end- end-- def confirmation_url(token, store)- if spree.respond_to?(:admin_user_confirmation_url)- spree.admin_user_confirmation_url(confirmation_token: token, host: store.formatted_url)- else- append_token(store.formatted_url, token)- end+ append_token(redirect_url.presence || store.formatted_url, token)endendenddiff --git a/spree/core/app/mailers/spree/base_mailer.rb b/spree/core/app/mailers/spree/base_mailer.rbindex 186d1e6079..5662bd0ba5 100644--- a/spree/core/app/mailers/spree/base_mailer.rb+++ b/spree/core/app/mailers/spree/base_mailer.rb@@ -63,7 +63,7 @@ module Spreesuperelse# Subclasses that call `mail` without wrapping their action in- # `with_store_locale` (e.g. Devise mailers, extensions) still get the+ # `with_store_locale` (e.g. extension mailers) still get the# store default locale, as `mail` applied before Spree 5.6.with_store_locale(current_store) { super }enddiff --git a/spree/core/app/views/spree/admin_user_mailer/confirmation_email.html.erb b/spree/core/app/views/spree/admin_user_mailer/confirmation_email.html.erbdeleted file mode 100644index 6d06fe358f..0000000000--- a/spree/core/app/views/spree/admin_user_mailer/confirmation_email.html.erb+++ /dev/null@@ -1,7 +0,0 @@-<%= render layout: 'spree/shared/mailer_hero' do %>- <h1><%= Spree.t('admin_user_mailer.confirmation_email.action') %></h1>- <p class="greeting"><%= Spree.t('admin_user_mailer.confirmation_email.greeting', name: @user.first_name.presence || @user.email) %></p>- <p><%= Spree.t('admin_user_mailer.confirmation_email.instructions', store_name: @current_store.name) %></p>- <%= render 'spree/shared/mailer_button', url: @confirmation_url, label: Spree.t('admin_user_mailer.confirmation_email.action') %>- <p class="sub"><%= Spree.t('admin_user_mailer.confirmation_email.ignore_notice') %></p>-<% end %>diff --git a/spree/core/config/locales/en.yml b/spree/core/config/locales/en.ymlindex 745abc490b..75e68c9f08 100644--- a/spree/core/config/locales/en.yml+++ b/spree/core/config/locales/en.yml@@ -577,45 +577,6 @@ en:address_book:save: Savesuccessfully_created: New address has been successfully created- devise:- confirmations:- confirmed: Your account was successfully confirmed. You are now signed in.- send_instructions: You will receive an email with instructions about how to confirm your account in a few minutes.- failure:- inactive: Your account was not activated yet.- invalid: Invalid email or password.- invalid_token: Invalid authentication token.- locked: Your account is locked.- timeout: Your session expired, please sign in again to continue.- too_many_attempts: Too many attempts. Please wait a moment and try again.- unauthenticated: You need to sign in or sign up before continuing.- unconfirmed: You have to confirm your account before continuing.- mailer:- confirmation_instructions:- subject: Confirmation instructions- reset_password_instructions:- subject: Reset password instructions- unlock_instructions:- subject: Unlock Instructions- oauth_callbacks:- failure: Could not authorize you from %{kind} because "%{reason}".- success: Successfully authorized from %{kind} account.- unlocks:- send_instructions: You will receive an email with instructions about how to unlock your account in a few minutes.- unlocked: Your account was successfully unlocked. You are now signed in.- user_passwords:- user:- cannot_be_blank: Your password cannot be blank.- send_instructions: You will receive an email with instructions about how to reset your password in a few minutes.- updated: Your password was changed successfully. You are now signed in.- user_registrations:- destroyed: Bye! Your account was successfully cancelled. We hope to see you again soon.- inactive_signed_up: You have signed up successfully. However, we could not sign you in because your account is %{reason}.- signed_up: Welcome! You have signed up successfully.- updated: You updated your account successfully.- user_sessions:- signed_in: Signed in successfully.- signed_out: Signed out successfully.errors:messages:already_confirmed: was already confirmed@@ -676,12 +637,6 @@ en:adjustments_deleted: Adjustments Deletedadmin_locale: Admin localeadmin_user_mailer:- confirmation_email:- action: Confirm Email- greeting: Hi %{name},- ignore_notice: If you did not create this account, you can safely ignore this email.- instructions: Please confirm the email address for your %{store_name} admin account by clicking the button below.- subject: Email Confirmation Instructionspassword_reset_email:action: Reset Passwordexpiry_notice: This password reset link will expire shortly. If you did not request this, no action is needed.diff --git a/spree/core/lib/spree/core/controller_helpers/auth.rb b/spree/core/lib/spree/core/controller_helpers/auth.rbindex 08e1b28315..cdc3dd9929 100644--- a/spree/core/lib/spree/core/controller_helpers/auth.rb+++ b/spree/core/lib/spree/core/controller_helpers/auth.rb@@ -19,8 +19,7 @@ module Spree@current_ability ||= Spree.ability_class.new(try_spree_current_user, { store: current_store })end- # this will work for devise out of the box- # for other auth systems you will need to override this method+ # Works out of the box for the default auth; override for custom auth systems.def store_location(location = nil)return if try_spree_current_user@@ -35,13 +34,12 @@ module Spreeend# proxy method to *possible* spree_current_user method- # Authentication extensions (such as spree_auth_devise) are meant to provide spree_current_user+ # The host app (via authentication_helpers.rb) or an auth extension provides spree_current_userdef try_spree_current_user- # This one will be defined by apps looking to hook into Spree- # As per authentication_helpers.rb+ # Provided by the host app, per authentication_helpers.rbif respond_to?(:spree_current_user)spree_current_user- # This one will be defined by Devise+ # Fallback name used by some auth integrationselsif respond_to?(:current_spree_user)current_spree_userenddiff --git a/spree/core/lib/spree/core/previews/admin_user_preview.rb b/spree/core/lib/spree/core/previews/admin_user_preview.rbindex 1a98ee2834..a0b14b0ef6 100644--- a/spree/core/lib/spree/core/previews/admin_user_preview.rb+++ b/spree/core/lib/spree/core/previews/admin_user_preview.rb@@ -11,12 +11,4 @@ class Spree::AdminUserPreview < ActionMailer::PreviewSpree::PreviewData.store(locale))end-- def confirmation_email- Spree::AdminUserMailer.confirmation_email(- Spree::PreviewData.admin_user,- 'preview-token',- Spree::PreviewData.store(locale)- )- endenddiff --git a/spree/core/lib/spree/core/routes.rb b/spree/core/lib/spree/core/routes.rbindex bffae42d66..a931b9d987 100644--- a/spree/core/lib/spree/core/routes.rb+++ b/spree/core/lib/spree/core/routes.rb@@ -4,12 +4,10 @@ module Spreedef self.add_routes(&block)@spree_routes ||= []- # Anything that causes the application's routes to be reloaded,- # will cause this method to be called more than once- # i.e. https://github.com/plataformatec/devise/blob/31971e69e6a1bcf6c7f01eaaa44f227c4af5d4d2/lib/devise/rails.rb#L14- # In the case of Devise, this *only* happens in the production env- # This coupled with Rails 4's insistence that routes are not drawn twice,- # poses quite a serious problem.+ # Anything that causes the application's routes to be reloaded will cause+ # this method to be called more than once (in some setups only in the+ # production env). Coupled with Rails' insistence that routes are not+ # drawn twice, that poses quite a serious problem.## This is mainly why this whole file exists in the first place.#diff --git a/spree/core/spec/mailers/spree/admin_user_mailer_spec.rb b/spree/core/spec/mailers/spree/admin_user_mailer_spec.rbindex 991c6205b0..a3a1700164 100644--- a/spree/core/spec/mailers/spree/admin_user_mailer_spec.rb+++ b/spree/core/spec/mailers/spree/admin_user_mailer_spec.rb@@ -82,14 +82,4 @@ describe Spree::AdminUserMailer, type: :mailer doendendend-- describe '#confirmation_email' do- it 'sends the confirmation with the store-prefixed subject and token link' do- message = described_class.confirmation_email(admin_user, token, store)-- expect(message.to).to eq(['[email protected]'])- expect(message.subject).to eq("#{store.name} #{Spree.t('admin_user_mailer.confirmation_email.subject')}")- expect(message.body.encoded).to include("token=#{token}")- end- endenddiff --git a/spree/core/spec/mailers/spree/base_mailer_spec.rb b/spree/core/spec/mailers/spree/base_mailer_spec.rbindex a983693512..a6e348805e 100644--- a/spree/core/spec/mailers/spree/base_mailer_spec.rb+++ b/spree/core/spec/mailers/spree/base_mailer_spec.rb@@ -136,8 +136,8 @@ describe Spree::BaseMailer, type: :mailer doenddescribe '#mail store locale fallback' do- # Subclasses that call `mail` directly without `with_store_locale` — Devise- # mailers, extensions — must still render in the store default locale, as+ # Subclasses that call `mail` directly without `with_store_locale` — e.g.+ # extension mailers — must still render in the store default locale, as# `mail` guaranteed before Spree 5.6 via `set_email_locale`.let(:probe_mailer) dostub_const('LocaleProbeMailer', Class.new(described_class) dodiff --git a/spree/core/spec/services/spree/account/create_spec.rb b/spree/core/spec/services/spree/account/create_spec.rbindex 61aaa80ee1..3dbf98d2dd 100644--- a/spree/core/spec/services/spree/account/create_spec.rb+++ b/spree/core/spec/services/spree/account/create_spec.rb@@ -30,7 +30,7 @@ module Spreeendend- # did not add unhappy path because validations are included in spree_auth_devise gem+ # did not add unhappy path because validations live on the customer modelendendend