Replace deprecated Rails secrets

Use new credentials interface.
This commit is contained in:
Maikel Linke
2025-11-14 09:05:23 +11:00
parent c65fcc1072
commit e09853af0c
5 changed files with 5 additions and 8 deletions

View File

@@ -6,7 +6,7 @@ module Admin
class StripeAccountsController < Spree::Admin::BaseController
def connect
payload = params.permit(:enterprise_id).to_h
key = Openfoodnetwork::Application.config.secret_token
key = Openfoodnetwork::Application.credentials.secret_token
url_params = { state: JWT.encode(payload, key, 'HS256'), scope: "read_write" }
redirect_to Stripe::OAuth.authorize_url(url_params)
end

View File

@@ -74,9 +74,6 @@ Rails.application.configure do
allowed_warnings = [
# List strings here to allow matching deprecations.
#
# `Rails.application.secrets` is deprecated in favor of `Rails.application.credentials` and will be removed in Rails 7.2
"Rails.application.secrets",
"Passing the class as positional argument",
# Spree::CreditCard model aliases `cc_type` and has a method called `cc_type=` defined. Starting in Rails 7.2 `brand=` will not be calling `cc_type=` anymore. You may want to additionally define `brand=` to preserve the current behavior.

View File

@@ -6,7 +6,7 @@
# no regular words or you'll be exposed to dictionary attacks.
# Rails 4+ key for signing and encrypting cookies.
Openfoodnetwork::Application.config.secret_key_base = ENV["SECRET_TOKEN"]
Openfoodnetwork::Application.credentials.secret_key_base = ENV["SECRET_TOKEN"]
# Legacy secret_token variable. This is still used directly for encryption.
Openfoodnetwork::Application.config.secret_token = ENV["SECRET_TOKEN"]
Openfoodnetwork::Application.credentials.secret_token = ENV["SECRET_TOKEN"]

View File

@@ -41,7 +41,7 @@ module Stripe
def state
# Returns the original payload
key = Openfoodnetwork::Application.config.secret_token
key = Openfoodnetwork::Application.credentials.secret_token
JWT.decode(params["state"], key, true, algorithm: 'HS256')[0]
end

View File

@@ -10,7 +10,7 @@ module Stripe
let(:user) { create(:user) }
let(:enterprise) { create(:enterprise) }
let(:payload) { { "junk" => "Ssfs" } }
let(:state) { JWT.encode(payload, Openfoodnetwork::Application.config.secret_token) }
let(:state) { JWT.encode(payload, Openfoodnetwork::Application.credentials.secret_token) }
let(:params) { { "state" => state } }
let(:connector) { AccountConnector.new(user, params) }