spree_api 5.6.0.rc2 → 5.6.0.rc3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0b165c94c2975472728b228761cc6cb41f1a677a6368dc9a0be992b5840444cd
4
- data.tar.gz: 1ee381dfe91a8ccc58e959cec117f1beb992dde08b6c04488e18ea45baf1ec3c
3
+ metadata.gz: 1029d16c5aff295ae773e0c605d1c2003157c4efcfdc5ac5f4ef6edf073b0d68
4
+ data.tar.gz: 8778b2415f90f19df1f7631ff6df0f4f2508ec8ba7d4116f81f76fecf81dae49
5
5
  SHA512:
6
- metadata.gz: 71038600173f2b56747b328f32fab9030ade806d07f3823e1e3e261098f85bdf24d54b0e8c7eb131e669a1f856bbb84c0d6cd3bba2974eef2739c87b73e27ddd
7
- data.tar.gz: 8847edd08dbe74a437313d47add4fc557f5930dfdce57cca0b8812249e1f9ea40cc2416aef628e97a13a999777031bd6de381532a4093bceb6311f554854acb8
6
+ metadata.gz: d7f0f2b4eabc6fc302f18b8cdd76d3213360ba927f3a1f5690253e7443baf4778464c1a3c395f1fa29827f1a2acdb66849e6738bc1af7e6fd0f9a910bcf09ecd
7
+ data.tar.gz: 8db65610da6e5ff6bc2dd736050c19d6c9624f64e48ba56b85d0c6bcc935f3ba1a00ff2080643b35cda5c7d05e0c83f3510c75c09926e483ae4b15c93bdc39a5
@@ -10,7 +10,7 @@ module Spree
10
10
  # CSRF protection:
11
11
  # We deliberately do NOT use a CSRF token here. The threat model is fully
12
12
  # covered by the combination of:
13
- # - SameSite=Lax (dev) / SameSite=None; Secure (prod) on the refresh cookie
13
+ # - SameSite=Lax (http) / SameSite=None; Secure (https) on the refresh cookie
14
14
  # - Spree::AllowedOrigin allowlist enforced via Rack::Cors with credentials: true
15
15
  # - CORS preflight blocking cross-origin requests from non-allowlisted Origins
16
16
  # A double-submit CSRF token would only add value if the AllowedOrigin allowlist
@@ -48,8 +48,14 @@ module Spree
48
48
  cookies.signed[REFRESH_COOKIE_NAME].presence
49
49
  end
50
50
 
51
+ # Keyed off the request scheme, not the Rails env: Rails silently refuses to
52
+ # write a Secure cookie on a non-SSL request, so a production app served over
53
+ # plain http (local Docker image, http-only intranet) would never get the
54
+ # refresh cookie at all. SameSite=None requires Secure, so http falls back to
55
+ # Lax — fine for same-site setups (ports don't factor into site identity);
56
+ # cross-site dashboards need https anyway.
51
57
  def base_cookie_attributes
52
- if Rails.env.production?
58
+ if request.ssl?
53
59
  { secure: true, same_site: :none }
54
60
  else
55
61
  { secure: false, same_site: :lax }
@@ -7,17 +7,19 @@ module Spree
7
7
 
8
8
  # POST /api/v3/admin/customers/:customer_id/addresses
9
9
  def create
10
- @resource = @parent.addresses.new(address_attrs)
11
- authorize_resource!(@resource, :create)
10
+ authorize_resource!(Spree::Address.new(user_id: @parent.id), :create)
12
11
 
13
- ApplicationRecord.transaction do
14
- if @resource.save
15
- apply_default_flags(@resource)
16
- render json: serialize_resource(@resource.reload), status: :created
17
- else
18
- render_validation_error(@resource.errors)
19
- raise ActiveRecord::Rollback
20
- end
12
+ result = Spree.address_create_service.call(
13
+ address_params: address_attrs,
14
+ user: @parent,
15
+ default_billing: default_billing_flag,
16
+ default_shipping: default_shipping_flag
17
+ )
18
+
19
+ if result.success?
20
+ render json: serialize_resource(result.value), status: :created
21
+ else
22
+ render_validation_error(result.value.errors)
21
23
  end
22
24
  end
23
25
 
@@ -25,14 +27,17 @@ module Spree
25
27
  def update
26
28
  authorize_resource!(@resource)
27
29
 
28
- ApplicationRecord.transaction do
29
- if @resource.update(address_attrs)
30
- apply_default_flags(@resource)
31
- render json: serialize_resource(@resource.reload)
32
- else
33
- render_validation_error(@resource.errors)
34
- raise ActiveRecord::Rollback
35
- end
30
+ result = Spree.address_update_service.call(
31
+ address: @resource,
32
+ address_params: address_attrs,
33
+ default_billing: default_billing_flag,
34
+ default_shipping: default_shipping_flag
35
+ )
36
+
37
+ if result.success?
38
+ render json: serialize_resource(result.value)
39
+ else
40
+ render_validation_error(result.value.errors)
36
41
  end
37
42
  end
38
43
 
@@ -69,11 +74,12 @@ module Spree
69
74
  )
70
75
  end
71
76
 
72
- def apply_default_flags(address)
73
- updates = {}
74
- updates[:bill_address_id] = address.id if ActiveModel::Type::Boolean.new.cast(params[:is_default_billing])
75
- updates[:ship_address_id] = address.id if ActiveModel::Type::Boolean.new.cast(params[:is_default_shipping])
76
- @parent.update!(updates) if updates.any?
77
+ def default_billing_flag
78
+ ActiveModel::Type::Boolean.new.cast(params[:is_default_billing])
79
+ end
80
+
81
+ def default_shipping_flag
82
+ ActiveModel::Type::Boolean.new.cast(params[:is_default_shipping])
77
83
  end
78
84
  end
79
85
  end
@@ -35,6 +35,14 @@ module Spree
35
35
  end
36
36
  end
37
37
 
38
+ # DELETE /api/v3/store/customers/me/addresses/:id
39
+ def destroy
40
+ @resource.destroy!
41
+ head :no_content
42
+ rescue ActiveRecord::RecordNotDestroyed => e
43
+ render_validation_error(e.record.errors.presence || e.message)
44
+ end
45
+
38
46
  protected
39
47
 
40
48
  def set_parent
@@ -48,7 +48,7 @@ module Spree
48
48
  attribute :description do |product|
49
49
  next if product.description.blank?
50
50
 
51
- Nokogiri::HTML.fragment(product.description).text.squish
51
+ Spree::RichTextHelper.to_plain_text(product.description)
52
52
  end
53
53
 
54
54
  attribute :description_html do |product|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.6.0.rc2
4
+ version: 5.6.0.rc3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vendo Connect Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-07-17 00:00:00.000000000 Z
11
+ date: 2026-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rswag-specs
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - '='
74
74
  - !ruby/object:Gem::Version
75
- version: 5.6.0.rc2
75
+ version: 5.6.0.rc3
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - '='
81
81
  - !ruby/object:Gem::Version
82
- version: 5.6.0.rc2
82
+ version: 5.6.0.rc3
83
83
  description: Spree's API
84
84
  email:
85
85
  - hello@spreecommerce.org
@@ -380,9 +380,9 @@ licenses:
380
380
  - BSD-3-Clause
381
381
  metadata:
382
382
  bug_tracker_uri: https://github.com/spree/spree/issues
383
- changelog_uri: https://github.com/spree/spree/releases/tag/v5.6.0.rc2
383
+ changelog_uri: https://github.com/spree/spree/releases/tag/v5.6.0.rc3
384
384
  documentation_uri: https://docs.spreecommerce.org/
385
- source_code_uri: https://github.com/spree/spree/tree/v5.6.0.rc2
385
+ source_code_uri: https://github.com/spree/spree/tree/v5.6.0.rc3
386
386
  post_install_message:
387
387
  rdoc_options: []
388
388
  require_paths: