mirror of
https://github.com/System-End/theseus.git
synced 2026-04-19 16:38:18 +00:00
disallow hq-usps-ops on payment accounts
This commit is contained in:
parent
204c67f1cb
commit
665bc1dcd2
2 changed files with 16 additions and 1 deletions
|
|
@ -51,7 +51,9 @@ class HCB::PaymentAccountsController < ApplicationController
|
|||
end
|
||||
|
||||
def available_organizations
|
||||
current_user.hcb_oauth_connection.organizations
|
||||
current_user.hcb_oauth_connection.organizations.reject do |org|
|
||||
HCB::PaymentAccount::BLOCKED_ORGANIZATION_IDS.include?(org.id)
|
||||
end
|
||||
rescue => e
|
||||
Rails.logger.error "Failed to fetch HCB organizations: #{e.message}"
|
||||
[]
|
||||
|
|
|
|||
|
|
@ -24,8 +24,21 @@ class HCB::PaymentAccount < ApplicationRecord
|
|||
belongs_to :user
|
||||
belongs_to :oauth_connection, class_name: "HCB::OauthConnection", foreign_key: :hcb_oauth_connection_id
|
||||
|
||||
BLOCKED_ORGANIZATION_IDS = %w[hq-usps-ops].freeze
|
||||
|
||||
validates :organization_id, presence: true, uniqueness: { scope: :user_id }
|
||||
validates :organization_name, presence: true
|
||||
validate :organization_not_blocked
|
||||
|
||||
private
|
||||
|
||||
def organization_not_blocked
|
||||
if BLOCKED_ORGANIZATION_IDS.include?(organization_id)
|
||||
errors.add(:organization_id, "is not allowed for payment accounts")
|
||||
end
|
||||
end
|
||||
|
||||
public
|
||||
|
||||
def self.theseus_client
|
||||
HCBV4::Client.from_credentials(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue