@spree/docs 0.1.258 → 0.1.259
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -141,6 +141,8 @@ end
|
|
|
141
141
|
|
|
142
142
|
`find_or_create_user_from_oauth` returns the **user**, not the identity. It creates the `Spree::UserIdentity` row on first login (mapping `provider + uid → user`) and reuses it on subsequent logins — so repeat sign-ins land on the same Spree customer.
|
|
143
143
|
|
|
144
|
+
> **NOTE:** Any `access_token` and `refresh_token` you pass in `tokens` are stored on the identity and encrypted at rest with Active Record encryption. Configure the encryption keys in production (`bin/rails db:encryption:init`, then store the output in your encrypted credentials). Without them, Spree stores the tokens in plain text.
|
|
145
|
+
|
|
144
146
|
## Step 2: Register the Strategy
|
|
145
147
|
|
|
146
148
|
Add the strategy to a registry in `config/initializers/spree.rb`. **This is the only line that decides which API the provider serves** — `store_authentication_strategies` for customer login, `admin_authentication_strategies` for staff login. Register with both to allow the same provider on either surface. The key you choose here is what clients send as `provider` in the login payload.
|
|
@@ -182,7 +184,7 @@ The strategy is instantiated with the surface's user class automatically — `Sp
|
|
|
182
184
|
|
|
183
185
|
> **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.
|
|
184
186
|
|
|
185
|
-
> **WARNING:** `Spree::UserIdentity` validates that `provider` is a registered strategy
|
|
187
|
+
> **WARNING:** `Spree::UserIdentity` validates that `provider` is a key registered in the store, admin or seller strategy registry. Registration must happen during boot — before the first login attempt.
|
|
186
188
|
|
|
187
189
|
## Step 3: Call the Exchange Endpoint
|
|
188
190
|
|