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
Send a seller invitation to the seller panel
Damian Legawiec7bb5bf2fc768
diff --git a/docs/developer/customization/configuration.mdx b/docs/developer/customization/configuration.mdxindex 93a76e665c..c4f6091546 100644--- a/docs/developer/customization/configuration.mdx+++ b/docs/developer/customization/configuration.mdx@@ -23,6 +23,7 @@ Settings that describe the deployment rather than commerce behavior can be set w| Setting | Environment variable | What it configures ||---|---|---|| `dashboard_url` | `SPREE_DASHBOARD_URL` | Origin where the admin dashboard is hosted (e.g. `https://admin.my-shop.com`). Used for every link that sends someone into the dashboard: invitation emails, SSO redirects, and the first-run setup link printed by `db:seed`. |+| `seller_panel_url` | `SPREE_SELLER_PANEL_URL` | Origin where the marketplace seller panel is hosted (e.g. `https://sellers.my-shop.com`). Used for links sent to sellers, today the invitation email. Leave it unset on a marketplace with no seller panel — those links then open the dashboard. |This page lists only settings Spree 6 actually reads. Settings that exist for backwards compatibility are listed under [Deprecated settings](#deprecated-settings) rather than mixed in with the rest.diff --git a/docs/plans/6.0-multi-vendor-marketplace.md b/docs/plans/6.0-multi-vendor-marketplace.mdindex d23c9bf22a..1719ff5470 100644--- a/docs/plans/6.0-multi-vendor-marketplace.md+++ b/docs/plans/6.0-multi-vendor-marketplace.md@@ -737,6 +737,7 @@ Even before this lands, work touching adjacent areas should:- **The shared catalog ships as variant attributes plus one selection service** (RESOLVED 2026-08-16, shipped — Decision 11's Phase 1b). `spree_variants.seller_id` and `spree_variants.delivery_profile_id`, both nullable, and **two modes that never mix**: on an *owned* product (`products.seller_id` set) every variant is that seller's and ships as the product does — no other seller can create a variant there, so the variant's own columns carry no meaning and are kept blank by a normalizer; on a *master* product (`products.seller_id` nil, the shared catalog) each seller's row names its own seller and how it ships, falling back to the master's profile. The resolved answer is a plain read on the model (`resolved_seller`, `resolved_delivery_profile` — product's if owned, else the row's; no memo, no inheritance chain), and the API carries **one field each** (`seller_id`, `delivery_profile_id`), read resolved and written to the column, so a storefront never learns which mode it is in and a read-then-write round trip on an owned product changes nothing (the write is a no-op there). This deliberately departs from `Variant#tax_category`'s override-the-reader shape, and supersedes an earlier cut that modelled the seller as an inheritance-with-override and grew a second `own_*` name on the API to keep the round-trip safe — the domain has no override to model, so it needed neither. `Variant#digital?` moved onto the variant's own profile with it, which is what lets a download and its printed edition sit on one product. Condition is an `OptionType` shipped as **sample data, not a seed** (`db/sample_data/options.rb`, beside color; values new/refurbished/used): nothing in core keys on the word — the buy box groups by whatever option values it is given — so it is a merchant's choice, not an install prerequisite, and a store that sells only new goods never finds it on a fresh install, so it splits a product the way any axis does and the buy box keys on the option combination — a new buy box and a used one, at no extra cost. **The buy box is `Spree::Products::SelectBuyBox`** behind `Spree.product_buy_box_service`: computed on every read and never stored (it turns on price, stock and who is selling today, none of which hold still), ranking first-party ahead of sellers then cheapest, refusing to feature a seller who is suspended, onboarding or away, and still naming a variant when nothing is buyable so the page has a price to render. `purchasable?`/`in_stock?`/`backorderable?` now answer through the winner rather than `variants.any?` — a product is not purchasable because a suspended seller happens to hold stock — and `default_variant` prefers a first-party listing, since the headline price, SKU and the Omnibus `prior_price` are compliance claims about the operator's own pricing. **SKU uniqueness is scoped to the resolved seller** via a hand-written validation rather than a `scope:` option, because Rails' uniqueness validator reads the raw column and would have merged two sellers who each own a whole product into the nil scope. Cross-store binding is refused on the model (`seller`/`delivery_profile` must belong to the product's store), matching the pair already on Product. **Three pre-existing faults were fixed with it, each with a regression spec proven against the old code:** `Product#variants=`'s full-replacement delete was left as-is on the operator's path — the operator writes every seller's variants on a master — and the guard against a seller wiping a rival's rows lives at the seller branch, not the model (see "Writes never destroy another seller's variants" above), `Stock::Splitter::DeliveryProfile` and `Stock::Coordinator` re-keyed their memoisation off `product_id`, and `with_option_value_ids` now requires **one variant** to satisfy every axis (a `HAVING COUNT(DISTINCT option_type_id)` over one grouped subquery) instead of asking the product about each axis separately — "Blue AND XL" had matched a product selling a blue small beside a red XL, a live storefront bug independent of marketplaces. **Both search providers were fixed together**, since a filter's meaning is part of the provider contract and fixing one would have made results change when an operator installs the search gem: the Meilisearch document is per product, so its option values are a union across variants that cannot answer a per-variant question — the presenter now also emits `option_value_combination_ids` (one token per *combination* of values seen on the same variant) and a multi-axis filter asks for a whole combination, with single-axis filters and the disjunctive-facet queries unchanged. Whole combinations rather than pairs, because every pair holding on *some* variant is not the same as one variant holding them all — three variants (blue, XL, used), (blue, S, new) and (red, XL, new) satisfy each pair of "blue AND XL AND new" while none carries all three. Token count is exponential in the axis count, so it is capped (`MAX_COMBINATION_AXES`) and filters naming more axes fall back to the pairwise approximation. **The upgrade needs a reindex** — existing documents lack the field, so a multi-axis filter matches nothing until then; `search_reindex` is in the 5.6→6.0 manifest for exactly this and is a no-op on the database provider.- **Seller lifecycle → four workflows, never a writable `status`** (RESOLVED 2026-08-16, shipped). `Spree::Sellers::Invite` / `Approve` / `Suspend` / `Reject` (seams `seller_invite_workflow` and siblings), each with `validate` + `after_*` hooks and its own `seller.*` event. The Admin API exposes them as member actions (`POST invite`, `PATCH approve|suspend|reject`) and deliberately omits `status` from `permitted_params` — a PATCH that moved a seller would skip the mail, the payout provisioning and the extension hooks, which is exactly what `6.0-service-workflows.md` keeps out of a column write. Guards admit more than the linear path: `Approve` also lifts a suspension (clearing holiday mode with it) and revives a rejected applicant; `Suspend` is for a seller already on the marketplace while `Reject` is for one that never traded, so rejecting an approved seller is refused. Suspension and rejection reasons live in `metadata` rather than columns — each is a note about one event, and the next one has its own. Creation stays plain CRUD (it is not a lifecycle transition), so the default status is applied in an `after_initialize` on the model, as on `Spree::Fulfillment`.- **Lifecycle emails are seller-facing, event-driven, and skip the invitation** (RESOLVED 2026-08-16, shipped). `Spree::SellerMailer` (approved/suspended/rejected) in `spree_emails`, fired by `Spree::SellerEmailSubscriber` off the `seller.*` events the workflows already publish — nothing mails from a workflow step, so mail is one listener among several rather than something a transition waits on. Three departures from the legacy module: **no `seller.invited` email** (inviting creates an `Invitation`, which already mails the invitee — a second message would be the same news to the same address), **no marketplace-staff copies** (the legacy module mailed every store admin on approval and onboarding; staff read status in the dashboard, and per-admin fan-out across many sellers is the kind of noise merchants switch off — staff notifications ride the event/webhook surface), and **suspension/rejection reasons never appear in the email** (the operator's note is an internal record; the seller is asked to get in touch). Gated on a new `send_seller_transactional_emails` Store preference rather than the consumer one — sellers are a different audience, and silencing customer receipts must not silence seller mail. Onboarding started/completed emails wait for the onboarding task registry.+- **An invitation opens the app it is an invitation to** (RESOLVED 2026-08-17). The `admin_invitation_acceptance` route branches on `invitation.resource`: onto a `Spree::Seller` it resolves `Spree::Sellers::PanelUrl` (the `seller_panel_url` preference / SPREE_SELLER_PANEL_URL), everything else keeps the dashboard origin. Not cosmetic — the dashboard's acceptance page authenticates through the Admin API, which no seller may call, so a seller sent there could read the invitation and never accept it. The panel gets its own acceptance page and the seller API its own `auth/invitations/:id/{lookup,accept}`, parallel to the admin pair rather than subclassing it: what differs is the audience issued and the invitations it will touch, and both are the point — accepting a *staff* invitation here is refused as `not_found`, since it carries no seller membership and would mint a seller token for someone who runs no seller. With no panel deployed the link falls back to the dashboard; a marketplace that never onboards sellers by email need configure nothing.- **The seller panel is its own app and its own SDK** (RESOLVED 2026-08-17). `@spree/seller-sdk` beside `@spree/sdk` and `@spree/admin-sdk`, and `packages/seller-dashboard` (shell) + `packages/seller-dashboard-starter` (host) beside their dashboard counterparts — not a mode of the admin app. The credentials differ in kind, not degree: a seller JWT only (no secret-key equivalent exists), `X-Spree-Seller-Id` rather than `X-Spree-Store-Id` (the store is derived from the seller), and a refresh cookie whose name and path are deliberately not shared. Typing those as optional-but-meaningless on one client is how a panel ends up able to call the wrong API.**`@spree/dashboard-core` generalizes rather than forks**: it exported an `adminClient` singleton built from `createAdminClient`, so any host reusing the framework got the Admin API — the one thing Decision 10 forbids. Core now takes a registered client (`setApiClient`/`getApiClient`) that each host installs at boot; `adminClient` survives as a deprecated alias. Two further admin assumptions came out with it: the Tailwind source list hardcoded `@spree/dashboard` (so a second panel's own components were never scanned) and the store switcher built a typed `/$storeId` link that cannot compile against a router without that route. `@spree/dashboard-ui` is already headless and needed no change. One framework, two hosts — a fork would mean every registry and provider fix landing twice.- **The storefront sees a seller's profile, never their operational state** (RESOLVED 2026-08-16, shipped). `Spree::Api::V3::SellerSerializer` carries `name`, `slug`, `about`/`about_html` and the three image URLs — and nothing else. `status` and `sellable` are excluded on purpose (a seller a shopper can reach is sellable by definition), along with settlement/tax configuration, contact and billing addresses, team size and every timestamp; a spec asserts the exact key set so nothing leaks in later. The admin serializer extends this one rather than duplicating it, per the house rule. Store endpoints are read-only `index`/`show` scoped to `sellable` — a seller onboarding, suspended or away is neither listed nor fetchable (404), since listing them would advertise products nobody can buy — and resolve by slug or prefixed id so a storefront can route `/sellers/<slug>`. Products expose `seller_id` on **both** APIs without an expand (so a storefront can group or link by seller cheaply) plus `one :seller` behind `?expand=seller`; the admin serializer additionally carries `seller_name` for its list column. `Spree::Product` gains `seller_id` and `seller` to its ransack allowlists — without them the products-table filter silently matches nothing.diff --git a/packages/dashboard-core/src/api-client.ts b/packages/dashboard-core/src/api-client.tsindex 3269d1a7ec..1452bf296a 100644--- a/packages/dashboard-core/src/api-client.ts+++ b/packages/dashboard-core/src/api-client.ts@@ -33,9 +33,11 @@ export interface PanelApiClient {refresh(): Promise<PanelSession>logout(): Promise<void>/**- * Admin-only sign-in flows. A seller's panel has none of these: sellers- * arrive by invitation on the staff rail, and password reset and- * first-run setup are the marketplace's own.+ * Optional sign-in flows, because not every panel offers all of them.+ * Both panels accept invitations — each against its own API, so the+ * session that comes back carries the right audience. Password reset and+ * first-run setup remain the marketplace's own, so a seller's client+ * leaves them undefined.*/acceptInvitation?(id: string, token: string, params: unknown): Promise<PanelSession>resetPassword?(token: string, params: unknown): Promise<PanelSession>diff --git a/packages/seller-dashboard-starter/src/routeTree.gen.ts b/packages/seller-dashboard-starter/src/routeTree.gen.tsindex f899130695..3ba9e3c8b1 100644--- a/packages/seller-dashboard-starter/src/routeTree.gen.ts+++ b/packages/seller-dashboard-starter/src/routeTree.gen.ts@@ -12,6 +12,7 @@ import { Route as rootRouteImport } from './../../seller-dashboard/src/routes/__import { Route as loginRouteImport } from './../../seller-dashboard/src/routes/login'import { Route as authenticatedRouteImport } from './../../seller-dashboard/src/routes/_authenticated'import { Route as authenticatedIndexRouteImport } from './../../seller-dashboard/src/routes/_authenticated/index'+import { Route as acceptInvitationDotinvitationIdRouteImport } from './../../seller-dashboard/src/routes/accept-invitation.$invitationId'import { Route as authenticatedSellerIdRouteImport } from './../../seller-dashboard/src/routes/_authenticated/$sellerId'import { Route as IndexRouteImport } from './../../seller-dashboard/src/routes/_authenticated/$sellerId/index'import { Route as TeamRouteImport } from './../../seller-dashboard/src/routes/_authenticated/$sellerId/team'@@ -30,6 +31,12 @@ const authenticatedIndexRoute = authenticatedIndexRouteImport.update({path: '/',getParentRoute: () => authenticatedRoute,} as any)+const acceptInvitationDotinvitationIdRoute =+ acceptInvitationDotinvitationIdRouteImport.update({+ id: '/accept-invitation/$invitationId',+ path: '/accept-invitation/$invitationId',+ getParentRoute: () => rootRouteImport,+ } as any)const authenticatedSellerIdRoute = authenticatedSellerIdRouteImport.update({id: '/$sellerId',path: '/$sellerId',@@ -50,11 +57,13 @@ export interface FileRoutesByFullPath {'/': typeof authenticatedIndexRoute'/login': typeof loginRoute'/$sellerId': typeof authenticatedSellerIdRouteWithChildren+ '/accept-invitation/$invitationId': typeof acceptInvitationDotinvitationIdRoute'/$sellerId/team': typeof TeamRoute'/$sellerId/': typeof IndexRoute}export interface FileRoutesByTo {'/login': typeof loginRoute+ '/accept-invitation/$invitationId': typeof acceptInvitationDotinvitationIdRoute'/': typeof authenticatedIndexRoute'/$sellerId/team': typeof TeamRoute'/$sellerId': typeof IndexRoute@@ -64,20 +73,33 @@ export interface FileRoutesById {'/_authenticated': typeof authenticatedRouteWithChildren'/login': typeof loginRoute'/_authenticated/$sellerId': typeof authenticatedSellerIdRouteWithChildren+ '/accept-invitation/$invitationId': typeof acceptInvitationDotinvitationIdRoute'/_authenticated/': typeof authenticatedIndexRoute'/_authenticated/$sellerId/team': typeof TeamRoute'/_authenticated/$sellerId/': typeof IndexRoute}export interface FileRouteTypes {fileRoutesByFullPath: FileRoutesByFullPath- fullPaths: '/' | '/login' | '/$sellerId' | '/$sellerId/team' | '/$sellerId/'+ fullPaths:+ | '/'+ | '/login'+ | '/$sellerId'+ | '/accept-invitation/$invitationId'+ | '/$sellerId/team'+ | '/$sellerId/'fileRoutesByTo: FileRoutesByTo- to: '/login' | '/' | '/$sellerId/team' | '/$sellerId'+ to:+ | '/login'+ | '/accept-invitation/$invitationId'+ | '/'+ | '/$sellerId/team'+ | '/$sellerId'id:| '__root__'| '/_authenticated'| '/login'| '/_authenticated/$sellerId'+ | '/accept-invitation/$invitationId'| '/_authenticated/'| '/_authenticated/$sellerId/team'| '/_authenticated/$sellerId/'@@ -86,6 +108,7 @@ export interface FileRouteTypes {export interface RootRouteChildren {authenticatedRoute: typeof authenticatedRouteWithChildrenloginRoute: typeof loginRoute+ acceptInvitationDotinvitationIdRoute: typeof acceptInvitationDotinvitationIdRoute}declare module '@tanstack/react-router' {@@ -111,6 +134,13 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof authenticatedIndexRouteImportparentRoute: typeof authenticatedRoute}+ '/accept-invitation/$invitationId': {+ id: '/accept-invitation/$invitationId'+ path: '/accept-invitation/$invitationId'+ fullPath: '/accept-invitation/$invitationId'+ preLoaderRoute: typeof acceptInvitationDotinvitationIdRouteImport+ parentRoute: typeof rootRouteImport+ }'/_authenticated/$sellerId': {id: '/_authenticated/$sellerId'path: '/$sellerId'@@ -167,6 +197,7 @@ const authenticatedRouteWithChildren = authenticatedRoute._addFileChildren(const rootRouteChildren: RootRouteChildren = {authenticatedRoute: authenticatedRouteWithChildren,loginRoute: loginRoute,+ acceptInvitationDotinvitationIdRoute: acceptInvitationDotinvitationIdRoute,}export const routeTree = rootRouteImport._addFileChildren(rootRouteChildren)diff --git a/packages/seller-dashboard/package.json b/packages/seller-dashboard/package.jsonindex 7cf0f0e2ab..594c701e93 100644--- a/packages/seller-dashboard/package.json+++ b/packages/seller-dashboard/package.json@@ -39,7 +39,8 @@"lucide-react": "^0.545.0","react-hook-form": "^7.65.0","react-i18next": "^16.0.0",- "sonner": "^2.0.7"+ "sonner": "^2.0.7",+ "zod": "^4.4.3"},"peerDependencies": {"react": "^19.0.0",diff --git a/packages/seller-dashboard/src/locales/en.json b/packages/seller-dashboard/src/locales/en.jsonindex 44a17c950a..eba5613930 100644--- a/packages/seller-dashboard/src/locales/en.json+++ b/packages/seller-dashboard/src/locales/en.json@@ -12,6 +12,19 @@"failed": "That email and password did not match a seller account.","no_seller": "This account does not run a seller on this marketplace."},+ "accept_invitation": {+ "title": "Join the team",+ "subtitle": "You were invited as {{email}}. Set a password to finish.",+ "first_name": "First name",+ "last_name": "Last name",+ "password": "Password",+ "password_confirmation": "Confirm password",+ "submit": "Accept invitation",+ "submitting": "Accepting…",+ "failed": "That invitation could not be accepted. It may have expired, or the password was wrong.",+ "not_found": "This invitation is no longer valid. Ask whoever invited you to send a new one.",+ "invalid_link": "This link is missing its token. Open the link from your invitation email."+ },"seller_picker": {"title": "Choose a seller","subtitle": "You run more than one. Pick which to manage.",diff --git a/packages/seller-dashboard/src/pages/accept-invitation.tsx b/packages/seller-dashboard/src/pages/accept-invitation.tsxnew file mode 100644index 0000000000..50dc14b67b--- /dev/null+++ b/packages/seller-dashboard/src/pages/accept-invitation.tsx@@ -0,0 +1,121 @@+import { useAuth } from '@spree/dashboard-core'+import { Button, Field, FieldError, FieldGroup, FieldLabel, Input } from '@spree/dashboard-ui'+import { useQuery } from '@tanstack/react-query'+import { useState } from 'react'+import { useForm } from 'react-hook-form'+import { useTranslation } from 'react-i18next'+import { sellerClient } from '../api-client'+import { CenteredMessage } from '../components/centered-message'++interface AcceptValues {+ password: string+ password_confirmation: string+ first_name: string+ last_name: string+}++/**+ * Joining a seller's team from the emailed link.+ *+ * The invitation id and token in the URL are the whole credential — nobody is+ * signed in yet. Accepting returns a seller session, so the new member lands+ * in the panel rather than being bounced to a login form.+ */+export function AcceptInvitationPage({+ invitationId,+ token,+}: {+ invitationId: string+ token?: string+}) {+ const { t } = useTranslation()+ const { acceptInvitation } = useAuth()+ const [error, setError] = useState<string | null>(null)++ const {+ data: invitation,+ isLoading,+ error: lookupError,+ } = useQuery({+ queryKey: ['seller', 'invitation', invitationId],+ queryFn: () => sellerClient().auth.lookupInvitation(invitationId, token ?? ''),+ enabled: Boolean(token),+ retry: false,+ })++ const form = useForm<AcceptValues>({+ defaultValues: { password: '', password_confirmation: '', first_name: '', last_name: '' },+ })++ if (!token) return <CenteredMessage>{t('accept_invitation.invalid_link')}</CenteredMessage>+ if (isLoading) return <CenteredMessage>{t('common.loading')}</CenteredMessage>+ if (lookupError || !invitation) {+ return <CenteredMessage>{t('accept_invitation.not_found')}</CenteredMessage>+ }++ async function onSubmit(values: AcceptValues) {+ setError(null)+ try {+ await acceptInvitation(invitationId, token ?? '', values)+ // The index route decides where to go — it already knows how to skip+ // the picker for someone who runs exactly one seller.+ } catch {+ setError(t('accept_invitation.failed'))+ }+ }++ const { errors, isSubmitting } = form.formState++ return (+ <div className="flex min-h-screen items-center justify-center p-6">+ <div className="w-full max-w-sm">+ <h1 className="font-medium text-xl">{t('accept_invitation.title')}</h1>+ <p className="mt-1 mb-6 text-muted-foreground text-sm">+ {t('accept_invitation.subtitle', { email: invitation.email })}+ </p>++ <form onSubmit={form.handleSubmit(onSubmit)}>+ <FieldGroup>+ <Field>+ <FieldLabel htmlFor="first_name">{t('accept_invitation.first_name')}</FieldLabel>+ <Input id="first_name" {...form.register('first_name')} />+ </Field>++ <Field>+ <FieldLabel htmlFor="last_name">{t('accept_invitation.last_name')}</FieldLabel>+ <Input id="last_name" {...form.register('last_name')} />+ </Field>++ <Field>+ <FieldLabel htmlFor="password">{t('accept_invitation.password')}</FieldLabel>+ <Input+ id="password"+ type="password"+ aria-invalid={!!errors.password || undefined}+ {...form.register('password', { required: true })}+ />+ <FieldError errors={[errors.password]} />+ </Field>++ <Field>+ <FieldLabel htmlFor="password_confirmation">+ {t('accept_invitation.password_confirmation')}+ </FieldLabel>+ <Input+ id="password_confirmation"+ type="password"+ {...form.register('password_confirmation')}+ />+ </Field>++ {error && <p className="text-destructive text-sm">{error}</p>}++ <Button type="submit" disabled={isSubmitting}>+ {isSubmitting ? t('accept_invitation.submitting') : t('accept_invitation.submit')}+ </Button>+ </FieldGroup>+ </form>+ </div>+ </div>+ )+}diff --git a/packages/seller-dashboard/src/routeTree.gen.ts b/packages/seller-dashboard/src/routeTree.gen.tsindex 79dd91c46d..21a33cd7ed 100644--- a/packages/seller-dashboard/src/routeTree.gen.ts+++ b/packages/seller-dashboard/src/routeTree.gen.ts@@ -12,6 +12,7 @@ import { Route as rootRouteImport } from './routes/__root'import { Route as loginRouteImport } from './routes/login'import { Route as authenticatedRouteImport } from './routes/_authenticated'import { Route as authenticatedIndexRouteImport } from './routes/_authenticated/index'+import { Route as acceptInvitationDotinvitationIdRouteImport } from './routes/accept-invitation.$invitationId'import { Route as authenticatedSellerIdRouteImport } from './routes/_authenticated/$sellerId'import { Route as IndexRouteImport } from './routes/_authenticated/$sellerId/index'import { Route as TeamRouteImport } from './routes/_authenticated/$sellerId/team'@@ -30,6 +31,12 @@ const authenticatedIndexRoute = authenticatedIndexRouteImport.update({path: '/',getParentRoute: () => authenticatedRoute,} as any)+const acceptInvitationDotinvitationIdRoute =+ acceptInvitationDotinvitationIdRouteImport.update({+ id: '/accept-invitation/$invitationId',+ path: '/accept-invitation/$invitationId',+ getParentRoute: () => rootRouteImport,+ } as any)const authenticatedSellerIdRoute = authenticatedSellerIdRouteImport.update({id: '/$sellerId',path: '/$sellerId',@@ -50,11 +57,13 @@ export interface FileRoutesByFullPath {'/': typeof authenticatedIndexRoute'/login': typeof loginRoute'/$sellerId': typeof authenticatedSellerIdRouteWithChildren+ '/accept-invitation/$invitationId': typeof acceptInvitationDotinvitationIdRoute'/$sellerId/team': typeof TeamRoute'/$sellerId/': typeof IndexRoute}export interface FileRoutesByTo {'/login': typeof loginRoute+ '/accept-invitation/$invitationId': typeof acceptInvitationDotinvitationIdRoute'/': typeof authenticatedIndexRoute'/$sellerId/team': typeof TeamRoute'/$sellerId': typeof IndexRoute@@ -64,20 +73,33 @@ export interface FileRoutesById {'/_authenticated': typeof authenticatedRouteWithChildren'/login': typeof loginRoute'/_authenticated/$sellerId': typeof authenticatedSellerIdRouteWithChildren+ '/accept-invitation/$invitationId': typeof acceptInvitationDotinvitationIdRoute'/_authenticated/': typeof authenticatedIndexRoute'/_authenticated/$sellerId/team': typeof TeamRoute'/_authenticated/$sellerId/': typeof IndexRoute}export interface FileRouteTypes {fileRoutesByFullPath: FileRoutesByFullPath- fullPaths: '/' | '/login' | '/$sellerId' | '/$sellerId/team' | '/$sellerId/'+ fullPaths:+ | '/'+ | '/login'+ | '/$sellerId'+ | '/accept-invitation/$invitationId'+ | '/$sellerId/team'+ | '/$sellerId/'fileRoutesByTo: FileRoutesByTo- to: '/login' | '/' | '/$sellerId/team' | '/$sellerId'+ to:+ | '/login'+ | '/accept-invitation/$invitationId'+ | '/'+ | '/$sellerId/team'+ | '/$sellerId'id:| '__root__'| '/_authenticated'| '/login'| '/_authenticated/$sellerId'+ | '/accept-invitation/$invitationId'| '/_authenticated/'| '/_authenticated/$sellerId/team'| '/_authenticated/$sellerId/'@@ -86,6 +108,7 @@ export interface FileRouteTypes {export interface RootRouteChildren {authenticatedRoute: typeof authenticatedRouteWithChildrenloginRoute: typeof loginRoute+ acceptInvitationDotinvitationIdRoute: typeof acceptInvitationDotinvitationIdRoute}declare module '@tanstack/react-router' {@@ -111,6 +134,13 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof authenticatedIndexRouteImportparentRoute: typeof authenticatedRoute}+ '/accept-invitation/$invitationId': {+ id: '/accept-invitation/$invitationId'+ path: '/accept-invitation/$invitationId'+ fullPath: '/accept-invitation/$invitationId'+ preLoaderRoute: typeof acceptInvitationDotinvitationIdRouteImport+ parentRoute: typeof rootRouteImport+ }'/_authenticated/$sellerId': {id: '/_authenticated/$sellerId'path: '/$sellerId'@@ -167,6 +197,7 @@ const authenticatedRouteWithChildren = authenticatedRoute._addFileChildren(const rootRouteChildren: RootRouteChildren = {authenticatedRoute: authenticatedRouteWithChildren,loginRoute: loginRoute,+ acceptInvitationDotinvitationIdRoute: acceptInvitationDotinvitationIdRoute,}export const routeTree = rootRouteImport._addFileChildren(rootRouteChildren)diff --git a/packages/seller-dashboard/src/routes/accept-invitation.$invitationId.tsx b/packages/seller-dashboard/src/routes/accept-invitation.$invitationId.tsxnew file mode 100644index 0000000000..dd4ae11286--- /dev/null+++ b/packages/seller-dashboard/src/routes/accept-invitation.$invitationId.tsx@@ -0,0 +1,19 @@+import { createFileRoute } from '@tanstack/react-router'+import { z } from 'zod/v4'+import { AcceptInvitationPage } from '../pages/accept-invitation'++const acceptSearchSchema = z.object({+ token: z.string().min(1).optional(),+})++export const Route = createFileRoute('/accept-invitation/$invitationId')({+ validateSearch: acceptSearchSchema,+ component: AcceptInvitation,+})++function AcceptInvitation() {+ const { invitationId } = Route.useParams()+ const { token } = Route.useSearch()++ return <AcceptInvitationPage invitationId={invitationId} token={token} />+}diff --git a/packages/seller-dashboard/src/vite/index.ts b/packages/seller-dashboard/src/vite/index.tsindex 908e98573c..c37b2162ec 100644--- a/packages/seller-dashboard/src/vite/index.ts+++ b/packages/seller-dashboard/src/vite/index.ts@@ -62,6 +62,7 @@ function sellerRouterPlugin(hostRoot: string, options: SpreeSellerDashboardPlugiconst virtualRouteConfig = rootRoute('__root.tsx', [route('/login', 'login.tsx'),+ route('/accept-invitation/$invitationId', 'accept-invitation.$invitationId.tsx'),layout('_authenticated.tsx', [index('_authenticated/index.tsx'),route('/$sellerId', '_authenticated/$sellerId.tsx', [diff --git a/packages/seller-sdk/src/seller-client.ts b/packages/seller-sdk/src/seller-client.tsindex d0050dfe9e..719fa3d702 100644--- a/packages/seller-sdk/src/seller-client.ts+++ b/packages/seller-sdk/src/seller-client.ts@@ -1,5 +1,5 @@import type { RequestFn, RequestOptions } from '@spree/sdk-core'-import type { AuthTokens, Profile, SellerSummary, TeamMember } from './types'+import type { AuthTokens, Invitation, Profile, SellerSummary, TeamMember } from './types'/*** Resource methods for the Spree Seller API — the marketplace seller panel.@@ -33,6 +33,42 @@ export class SellerClient {/** Sign-in methods this marketplace offers sellers, for the login page. */providers: (options?: RequestOptions): Promise<{ providers: unknown[] }> =>this.request<{ providers: unknown[] }>('GET', '/auth/providers', options),++ /**+ * Reads an invitation from the emailed link, before anyone signs in — the+ * page needs the invited address to decide whether it is asking someone to+ * set a password or to confirm the one they already have.+ */+ lookupInvitation: (+ invitationId: string,+ token: string,+ options?: RequestOptions,+ ): Promise<Invitation> =>+ this.request<Invitation>('GET', `/auth/invitations/${invitationId}/lookup`, {+ ...options,+ params: { token },+ }),++ /**+ * Accepts the invitation and returns a signed-in seller session, so the+ * new member lands in the panel rather than on a login form.+ */+ acceptInvitation: (+ invitationId: string,+ token: string,+ params: {+ password?: string+ password_confirmation?: string+ first_name?: string+ last_name?: string+ },+ options?: RequestOptions,+ ): Promise<AuthTokens> =>+ this.request<AuthTokens>('POST', `/auth/invitations/${invitationId}/accept`, {+ ...options,+ params: { token },+ body: params,+ }),}/**diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 4c837b4999..f80050fc62 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -689,6 +689,9 @@ importers:sonner:specifier: ^2.0.7+ zod:+ specifier: ^4.4.3+ version: 4.4.3devDependencies:'@biomejs/biome':specifier: 2.4.13diff --git a/spree/api/app/controllers/spree/api/v3/seller/invitation_acceptances_controller.rb b/spree/api/app/controllers/spree/api/v3/seller/invitation_acceptances_controller.rbnew file mode 100644index 0000000000..350852c630--- /dev/null+++ b/spree/api/app/controllers/spree/api/v3/seller/invitation_acceptances_controller.rb@@ -0,0 +1,150 @@+module Spree+ module Api+ module V3+ module Seller+ # Public invitation acceptance for the seller panel — mounted under+ # `/api/v3/seller/auth/...` so the issued refresh-token cookie's path+ # matches `/auth/refresh`.+ #+ # Parallel to the admin controller rather than a subclass of it, per+ # Decision 10: what differs is the audience it issues and the+ # invitations it will touch, and both are the point.+ class InvitationAcceptancesController < Spree::Api::V3::BaseController+ include Spree::Api::V3::Seller::AuthCookies+ include Spree::Api::V3::JwtAuthentication++ # No `skip_scope_check!`: this extends the plain v3 base, which has+ # no authentication or scope gate to lift. The emailed token is the+ # only credential, exactly as on the admin twin.+ rate_limit to: Spree::Api::Config[:rate_limit_login],+ within: Spree::Api::Config[:rate_limit_window].seconds,+ store: Rails.cache,+ only: [:lookup, :accept],+ with: -> { render_rate_limited(limit: Spree::Api::Config[:rate_limit_login]) }++ # GET /api/v3/seller/auth/invitations/:id/lookup?token=:token+ def lookup+ return unless load_invitation++ render json: Spree.api.seller_invitation_serializer.new(@invitation).serializable_hash+ end++ # POST /api/v3/seller/auth/invitations/:id/accept?token=:token+ # Body: { password?, password_confirmation?, first_name?, last_name? }+ def accept+ return unless load_invitation++ user = resolve_or_create_invitee(@invitation)+ return if performed?++ @invitation.invitee = user+ @invitation.accept!++ set_refresh_cookie(+ Spree::RefreshToken.create_for(+ user,+ audience: Spree::Api::V3::JwtAuthentication::JWT_AUDIENCE_SELLER,+ request_env: request_env_for_token+ )+ )++ render json: auth_response(user)+ rescue ActiveRecord::RecordInvalid => e+ render_validation_error(e.record.errors)+ end++ private++ # Only invitations onto a seller are acceptable here. A staff+ # invitation carries no seller membership, so accepting one through+ # this endpoint would mint a seller token for someone who runs no+ # seller — and it is indistinguishable from "not found" on purpose,+ # since the caller is unauthenticated either way.+ #+ # Token mismatch is treated identically to "not found" to avoid+ # leaking whether an ID exists.+ def load_invitation+ decoded_id = Spree::Invitation.decode_prefixed_id(params[:id])+ @invitation = Spree::Invitation.pending.not_expired.+ where(resource_type: Spree::Seller.to_s).+ find_by(id: decoded_id, token: params[:token])++ unless @invitation+ render_error(+ code: ErrorHandler::ERROR_CODES[:record_not_found],+ message: Spree.t(:invitation_not_acceptable),+ status: :not_found+ )+ return false+ end++ true+ end++ # Email match between the invitation and any existing account is+ # implicit: we look the user up by `invitation.email`, never by a+ # client-supplied email. The token is the credential.+ def resolve_or_create_invitee(invitation)+ existing = Spree.admin_user_class.find_by(email: invitation.email)+ return authenticate_existing(existing) if existing++ create_new_invitee(invitation)+ end++ def authenticate_existing(user)+ return user if user.valid_password?(params[:password].to_s)++ render_error(+ code: ErrorHandler::ERROR_CODES[:authentication_failed],+ message: Spree.t(:invalid_password),+ status: :unauthorized+ )+ nil+ end++ def create_new_invitee(invitation)+ if params[:password].blank?+ render_error(+ code: ErrorHandler::ERROR_CODES[:parameter_missing],+ message: Spree.t(:password_required_to_create_account),+ status: :unprocessable_content+ )+ return nil+ end++ Spree.admin_user_class.create!(signup_params(invitation))+ end++ def signup_params(invitation)+ params.permit(:password, :password_confirmation, :first_name, :last_name).+ merge(email: invitation.email)+ end++ # Same shape as the login response, so the panel can sign the new+ # member straight in rather than bouncing them to a login form.+ def auth_response(user)+ {+ token: generate_jwt(user, audience: Spree::Api::V3::JwtAuthentication::JWT_AUDIENCE_SELLER),+ user: Spree.api.seller_team_member_serializer.new(+ user, params: { store: @invitation.store }+ ).to_h,+ sellers: serialized_sellers(user)+ }+ end++ def serialized_sellers(user)+ user.sellers.map { |seller| { id: seller.prefixed_id, name: seller.name, status: seller.status } }+ end++ def request_env_for_token+ { ip_address: request.remote_ip, user_agent: request.user_agent&.truncate(255) }+ end++ def jwt_expiration+ Spree::Api::Config[:admin_jwt_expiration]+ end+ end+ end+ end+ end+enddiff --git a/spree/api/config/routes.rb b/spree/api/config/routes.rbindex dc558b913f..4480936087 100644--- a/spree/api/config/routes.rb+++ b/spree/api/config/routes.rb@@ -659,6 +659,11 @@ Spree::Core::Engine.add_routes dopost 'auth/logout', to: 'auth#logout'get 'auth/providers', to: 'auth#providers'+ # Public invitation acceptance — unauthenticated; the prefixed ID ++ # token in the emailed link are the credential.+ get 'auth/invitations/:id/lookup', to: 'invitation_acceptances#lookup'+ post 'auth/invitations/:id/accept', to: 'invitation_acceptances#accept'+get 'me', to: 'me#show'# The seller's own record. Singular — there is exactly one seller indiff --git a/spree/api/spec/controllers/spree/api/v3/seller/invitation_acceptances_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/seller/invitation_acceptances_controller_spec.rbnew file mode 100644index 0000000000..1086038ce1--- /dev/null+++ b/spree/api/spec/controllers/spree/api/v3/seller/invitation_acceptances_controller_spec.rb@@ -0,0 +1,112 @@+require 'spec_helper'++RSpec.describe Spree::Api::V3::Seller::InvitationAcceptancesController, type: :controller do+ render_views++ let(:store) { @default_store }+ let(:seller) { create(:seller, :approved, store: store) }+ let(:inviter) { create(:admin_user) }+ let(:invitation) do+ create(:invitation, resource: seller, inviter: inviter, email: '[email protected]')+ end++ describe 'GET #lookup' do+ it 'describes the invitation to someone holding the token' do+ get :lookup, params: { id: invitation.prefixed_id, token: invitation.token }, as: :json++ expect(response).to have_http_status(:ok)+ expect(json_response['email']).to eq('[email protected]')+ end++ it 'refuses a wrong token' do+ get :lookup, params: { id: invitation.prefixed_id, token: 'wrong' }, as: :json++ expect(response).to have_http_status(:not_found)+ end++ # The seller panel must not become a way to accept a staff invitation:+ # that carries no seller membership, so it would mint a seller token for+ # someone who runs no seller.+ it 'refuses an invitation onto the store' do+ staff = create(:invitation, resource: store, inviter: inviter)++ get :lookup, params: { id: staff.prefixed_id, token: staff.token }, as: :json++ expect(response).to have_http_status(:not_found)+ end+ end++ describe 'POST #accept' do+ it 'creates the account and signs them in as a seller' do+ post :accept,+ params: {+ id: invitation.prefixed_id, token: invitation.token,+ password: 'sekrit123', password_confirmation: 'sekrit123',+ first_name: 'New', last_name: 'Comer'+ },+ as: :json++ expect(response).to have_http_status(:ok)+ expect(json_response['user']['email']).to eq('[email protected]')+ expect(json_response['sellers'].pluck('id')).to eq([seller.prefixed_id])+ expect(invitation.reload).to be_accepted+ end++ # The whole point of the branch: the token this endpoint issues is a+ # seller token, so the panel it lands on can actually use it.+ it 'issues a seller-audience token' do+ post :accept,+ params: {+ id: invitation.prefixed_id, token: invitation.token,+ password: 'sekrit123', password_confirmation: 'sekrit123'+ },+ as: :json++ payload = JWT.decode(+ json_response['token'], Rails.application.secret_key_base, true, algorithm: 'HS256'+ ).first++ expect(payload['aud']).to eq(Spree::Api::V3::JwtAuthentication::JWT_AUDIENCE_SELLER)+ end++ it 'requires a password when the account does not exist yet' do+ post :accept, params: { id: invitation.prefixed_id, token: invitation.token }, as: :json++ expect(response).to have_http_status(:unprocessable_content)+ expect(invitation.reload).not_to be_accepted+ end++ context 'when the invitee already has an account' do+ let!(:existing) { create(:admin_user, email: '[email protected]', password: 'sekrit123') }++ it 'signs them in with their existing password' do+ post :accept,+ params: { id: invitation.prefixed_id, token: invitation.token, password: 'sekrit123' },+ as: :json++ expect(response).to have_http_status(:ok)+ expect(seller.reload.users).to include(existing)+ end++ it 'refuses a wrong password' do+ post :accept,+ params: { id: invitation.prefixed_id, token: invitation.token, password: 'nope' },+ as: :json++ expect(response).to have_http_status(:unauthorized)+ expect(invitation.reload).not_to be_accepted+ end+ end++ it 'refuses an invitation onto the store' do+ staff = create(:invitation, resource: store, inviter: inviter)++ post :accept,+ params: { id: staff.prefixed_id, token: staff.token, password: 'sekrit123' },+ as: :json++ expect(response).to have_http_status(:not_found)+ expect(staff.reload).not_to be_accepted+ end+ end+enddiff --git a/spree/api/spec/requests/seller_invitation_flow_spec.rb b/spree/api/spec/requests/seller_invitation_flow_spec.rbnew file mode 100644index 0000000000..f06b0c5b1e--- /dev/null+++ b/spree/api/spec/requests/seller_invitation_flow_spec.rb@@ -0,0 +1,41 @@+require 'spec_helper'++# End-to-end over real HTTP: the link in the email, then the two endpoints it+# leads to. Unit specs cover the controller in isolation; this proves the+# routes are mounted and reachable as the mail addresses them.+RSpec.describe 'seller invitation flow', type: :request do+ let(:store) { @default_store }+ let(:seller) { create(:seller, :approved, store: store) }+ # Carries the seller's seeded role, exactly as `Seller::TeamController`+ # creates it — that role is what `after_accept` turns into membership.+ let(:invitation) do+ create(:invitation, resource: seller, inviter: create(:admin_user),+ email: '[email protected]', role: seller.default_user_role)+ end++ it 'walks the emailed link through to a signed-in seller session' do+ Spree::Config[:seller_panel_url] = 'https://sellers.example.com'+ url = Rails.application.routes.url_helpers.admin_invitation_acceptance_url(invitation)+ expect(url).to start_with('https://sellers.example.com/accept-invitation/')++ get "/api/v3/seller/auth/invitations/#{invitation.prefixed_id}/lookup",+ params: { token: invitation.token }+ expect(response).to have_http_status(:ok)++ post "/api/v3/seller/auth/invitations/#{invitation.prefixed_id}/accept",+ params: { token: invitation.token, password: 'sekrit123', password_confirmation: 'sekrit123' }+ body = JSON.parse(response.body)+ expect(response).to have_http_status(:ok)++ # The token must work on the seller API it was issued for.+ get '/api/v3/seller/me', headers: {+ 'Authorization' => "Bearer #{body['token']}",+ 'X-Spree-Seller-Id' => seller.prefixed_id+ }+ me = JSON.parse(response.body)+ expect(response).to have_http_status(:ok)+ expect(me['permission_keys']).to be_present+ ensure+ Spree::Config[:seller_panel_url] = nil+ end+enddiff --git a/spree/core/app/finders/spree/sellers/panel_url.rb b/spree/core/app/finders/spree/sellers/panel_url.rbnew file mode 100644index 0000000000..b8c5b8485f--- /dev/null+++ b/spree/core/app/finders/spree/sellers/panel_url.rb@@ -0,0 +1,33 @@+module Spree+ module Sellers+ # Origin where the seller panel is hosted, for links that send a seller+ # into it — today the invitation email.+ #+ # Deliberately its own resolver rather than a branch inside+ # `Spree::Stores::DashboardUrl`: the two are different apps for different+ # audiences, and the dashboard's fallback chain (the `/dashboard` mount+ # this app serves, the Vite dev server on 5173) names origins where no+ # seller panel is running.+ #+ # Resolution order, most authoritative first:+ #+ # 1. the `seller_panel_url` preference / SPREE_SELLER_PANEL_URL+ # 2. the dashboard origin, as a last resort+ #+ # The fallback is deliberate. A marketplace that has not deployed a panel+ # still has to send a working invitation, and the staff dashboard at least+ # exists; sending nowhere would be worse. Configure+ # SPREE_SELLER_PANEL_URL and sellers land on their own app.+ class PanelUrl+ # @param store [Spree::Store, nil] store whose URL ends the fallback chain+ # @return [String] origin without a trailing slash, e.g. +https://sellers.shop.com++ def self.call(store: nil)+ configured = Spree::Config[:seller_panel_url].presence++ return configured.to_s.chomp('/') if configured++ Spree::Stores::DashboardUrl.call(store: store)+ end+ end+ end+enddiff --git a/spree/core/config/locales/en.yml b/spree/core/config/locales/en.ymlindex fc041c04da..caf06302d7 100644--- a/spree/core/config/locales/en.yml+++ b/spree/core/config/locales/en.yml@@ -1061,6 +1061,7 @@ en:internationalization: Internationalizationinvalid_credit_card: Invalid credit card.invalid_exchange_variant: Invalid exchange variant.+ invalid_password: Invalid password.inventory: Inventoryinvitation_accepted: Invitation accepted!invitation_already_accepted: This invitation has already been accepted.@@ -1076,6 +1077,7 @@ en:link_description: 'To accept this invitation, please click the link below:'subject: Invitation to join %{resource_name}thanks: Thank you,+ invitation_not_acceptable: Invitation not found, expired, or already accepted.invitation_role_resource_mismatch: must belong to the same store or seller as the invitationinvitations: Invitationsinvited_by: Invited by@@ -1243,6 +1245,7 @@ en:page: Pagepages: Pagespassword: Password+ password_required_to_create_account: Password is required to create your account.path: Pathpay: Paypayment: Paymentdiff --git a/spree/core/config/routes.rb b/spree/core/config/routes.rbindex d608e52781..f5e75309c0 100644--- a/spree/core/config/routes.rb+++ b/spree/core/config/routes.rb@@ -41,9 +41,18 @@ Rails.application.routes.draw doendend# Used by admin mailers; the SPA derives the URL from `window.location.origin` instead.+ #+ # Which app the link opens follows what the invitation is *to*. An+ # invitation onto a seller has to land on the seller panel: the dashboard's+ # acceptance page authenticates through the Admin API, which no seller may+ # call, so a seller sent there could read the invitation and never accept it.direct :admin_invitation_acceptance do |invitation, _options = {}|path = "/accept-invitation/#{invitation.prefixed_id}?token=#{invitation.token}"- base = Spree::Stores::DashboardUrl.call(store: invitation.store)+ base = if invitation.resource.is_a?(Spree::Seller)+ Spree::Sellers::PanelUrl.call(store: invitation.store)+ else+ Spree::Stores::DashboardUrl.call(store: invitation.store)+ endbase.present? ? "#{base}#{path}" : pathenddiff --git a/spree/core/lib/spree/core/configuration.rb b/spree/core/lib/spree/core/configuration.rbindex c482ee4b3c..d66a7cae61 100644--- a/spree/core/lib/spree/core/configuration.rb+++ b/spree/core/lib/spree/core/configuration.rb@@ -32,6 +32,13 @@ module Spree# initializer — the setup link is printed by `db:seed`, before there is# any way to configure a running app.preference :dashboard_url, :string, default: nil, env: 'SPREE_DASHBOARD_URL'+ # Origin where the seller panel is hosted (e.g. `https://sellers.shop.com`).+ # Separate from `dashboard_url` because the two are different apps for+ # different audiences: a seller invitation sent to the staff dashboard+ # lands on a page that authenticates against the Admin API, which no+ # seller may call. Unset on a marketplace that runs no panel, in which+ # case seller invitations fall back to the dashboard origin.+ preference :seller_panel_url, :string, default: nil, env: 'SPREE_SELLER_PANEL_URL'preference :allow_checkout_on_gateway_error, :boolean, default: false, deprecated: 'Nothing reads this in Spree 6 — completion checks whether payments cover the total, so a failed gateway call never completes an order'preference :allow_empty_price_amount, :boolean, default: falsepreference :alternative_shipping_phone, :boolean, default: false, deprecated: 'Nothing reads this in Spree 6'diff --git a/spree/core/spec/mailers/spree/invitation_mailer_spec.rb b/spree/core/spec/mailers/spree/invitation_mailer_spec.rbindex d09c4a6b87..53bee8473b 100644--- a/spree/core/spec/mailers/spree/invitation_mailer_spec.rb+++ b/spree/core/spec/mailers/spree/invitation_mailer_spec.rb@@ -88,6 +88,38 @@ RSpec.describe Spree::InvitationMailer, type: :mailer do"https://admin.example.com/accept-invitation/#{invitation.prefixed_id}")end++ # An invitation onto a seller has to open the seller panel: the+ # dashboard's acceptance page authenticates through the Admin API,+ # which no seller may call.+ context 'for an invitation onto a seller' do+ let(:seller) { create(:seller, store: store) }+ let(:invitation) do+ create(:invitation, email: '[email protected]', inviter: inviter,+ resource: seller, skip_email: true)+ end++ before { Spree::Config[:seller_panel_url] = 'https://sellers.example.com' }+ after { Spree::Config[:seller_panel_url] = nil }++ it 'points at the seller panel rather than the dashboard' do+ expect(mail.body.encoded).to include(+ "https://sellers.example.com/accept-invitation/#{invitation.prefixed_id}"+ )+ expect(mail.body.encoded).not_to include('https://admin.example.com/accept-invitation')+ end+ end++ # A marketplace that has not deployed a panel still has to send a+ # working link, and the dashboard at least exists.+ it 'falls back to the dashboard when no seller panel is configured' do+ seller = create(:seller, store: store)+ seller_invitation = create(:invitation, email: '[email protected]', inviter: inviter,+ resource: seller, skip_email: true)++ expect(Rails.application.routes.url_helpers.admin_invitation_acceptance_url(seller_invitation)).+ to start_with('https://admin.example.com/accept-invitation')+ endendcontext 'when neither the legacy gem nor admin_url is configured' do