diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..a307bd3 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,165 @@ + + + + + + + + + + { + "lastFilter": { + "state": "OPEN", + "assignee": "24c02" + } +} + { + "selectedUrlAndAccountId": { + "url": "https://github.com/hackclub/theseus.git", + "accountId": "3eaf51f9-f8da-43ac-8e0c-ec58d166ad1e" + } +} + { + "customColor": "", + "associatedIndex": 4 +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1765242806022 + + + + + + \ No newline at end of file diff --git a/Gemfile b/Gemfile index 2eeafcf..bf20d5f 100644 --- a/Gemfile +++ b/Gemfile @@ -176,3 +176,5 @@ gem "xsv", "~> 1.3" gem "phlex-pdf", "~> 0.1.2" gem "ttfunk", github: "24c02/ttfunk" + +gem "hcbv4", "~> 0.1" diff --git a/Gemfile.lock b/Gemfile.lock index 14f06d6..1307c03 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -238,6 +238,7 @@ GEM hashids (~> 1.0) hashids (1.0.6) hashie (5.0.0) + hcbv4 (0.1.1) honeybadger (5.28.0) logger ostruct @@ -719,6 +720,7 @@ DEPENDENCIES foreman (~> 0.88.1) good_job (~> 4.11) hashid-rails (~> 1.4) + hcbv4 (~> 0.1) honeybadger (~> 5.28) http (~> 5.2) ivymeter (~> 0.1.0) diff --git a/app/models/public/user.rb b/app/models/public/user.rb index 6474421..4dd04a0 100644 --- a/app/models/public/user.rb +++ b/app/models/public/user.rb @@ -7,6 +7,11 @@ # opted_out_of_map :boolean default(FALSE) # created_at :datetime not null # updated_at :datetime not null +# hca_id :string +# +# Indexes +# +# index_public_users_on_hca_id (hca_id) UNIQUE # class Public::User < ApplicationRecord has_many :login_codes diff --git a/app/models/user.rb b/app/models/user.rb index 23cbca6..008600a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -5,6 +5,7 @@ # id :bigint not null, primary key # back_office :boolean default(FALSE) # can_impersonate_public :boolean +# can_use_indicia :boolean default(FALSE), not null # can_warehouse :boolean # email :string # icon_url :string @@ -12,13 +13,14 @@ # username :string # created_at :datetime not null # updated_at :datetime not null +# hca_id :string # home_mid_id :bigint default(1), not null # home_return_address_id :bigint default(1), not null -# hca_id :string # slack_id :string # # Indexes # +# index_users_on_hca_id (hca_id) UNIQUE # index_users_on_home_mid_id (home_mid_id) # index_users_on_home_return_address_id (home_return_address_id) # diff --git a/db/migrate/20251218193911_add_can_use_indicia_to_users.rb b/db/migrate/20251218193911_add_can_use_indicia_to_users.rb new file mode 100644 index 0000000..8d31034 --- /dev/null +++ b/db/migrate/20251218193911_add_can_use_indicia_to_users.rb @@ -0,0 +1,5 @@ +class AddCanUseIndiciaToUsers < ActiveRecord::Migration[8.0] + def change + add_column :users, :can_use_indicia, :boolean, default: false, null: false + end +end diff --git a/db/migrate/20251218193936_create_hcb_oauth_connections.rb b/db/migrate/20251218193936_create_hcb_oauth_connections.rb new file mode 100644 index 0000000..4200443 --- /dev/null +++ b/db/migrate/20251218193936_create_hcb_oauth_connections.rb @@ -0,0 +1,12 @@ +class CreateHCBOauthConnections < ActiveRecord::Migration[8.0] + def change + create_table :hcb_oauth_connections do |t| + t.references :user, null: false, foreign_key: true + t.text :access_token_ciphertext + t.text :refresh_token_ciphertext + t.datetime :expires_at + + t.timestamps + end + end +end diff --git a/db/migrate/20251218193953_create_hcb_payment_accounts.rb b/db/migrate/20251218193953_create_hcb_payment_accounts.rb new file mode 100644 index 0000000..6054993 --- /dev/null +++ b/db/migrate/20251218193953_create_hcb_payment_accounts.rb @@ -0,0 +1,12 @@ +class CreateHCBPaymentAccounts < ActiveRecord::Migration[8.0] + def change + create_table :hcb_payment_accounts do |t| + t.references :user, null: false, foreign_key: true + t.references :hcb_oauth_connection, null: false, foreign_key: true + t.string :organization_id + t.string :organization_name + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 6a059c0..ba1d3c9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.0].define(version: 2025_12_11_000001) do +ActiveRecord::Schema[8.0].define(version: 2025_12_18_193953) do # These are extensions that must be enabled in order to support this database enable_extension "citext" enable_extension "pg_catalog.plpgsql" @@ -268,6 +268,27 @@ ActiveRecord::Schema[8.0].define(version: 2025_12_11_000001) do t.index ["scheduled_at"], name: "index_good_jobs_on_scheduled_at", where: "(finished_at IS NULL)" end + create_table "hcb_oauth_connections", force: :cascade do |t| + t.bigint "user_id", null: false + t.text "access_token_ciphertext" + t.text "refresh_token_ciphertext" + t.datetime "expires_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["user_id"], name: "index_hcb_oauth_connections_on_user_id" + end + + create_table "hcb_payment_accounts", force: :cascade do |t| + t.bigint "user_id", null: false + t.bigint "hcb_oauth_connection_id", null: false + t.string "organization_id" + t.string "organization_name" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["hcb_oauth_connection_id"], name: "index_hcb_payment_accounts_on_hcb_oauth_connection_id" + t.index ["user_id"], name: "index_hcb_payment_accounts_on_user_id" + end + create_table "letter_queues", force: :cascade do |t| t.string "name" t.string "slug" @@ -414,6 +435,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_12_11_000001) do t.bigint "home_mid_id", default: 1, null: false t.bigint "home_return_address_id", default: 1, null: false t.string "hca_id" + t.boolean "can_use_indicia", default: false, null: false t.index ["hca_id"], name: "index_users_on_hca_id", unique: true t.index ["home_mid_id"], name: "index_users_on_home_mid_id" t.index ["home_return_address_id"], name: "index_users_on_home_return_address_id" @@ -577,6 +599,9 @@ ActiveRecord::Schema[8.0].define(version: 2025_12_11_000001) do add_foreign_key "batches", "users" add_foreign_key "batches", "usps_mailer_ids", column: "letter_mailer_id_id" add_foreign_key "batches", "warehouse_templates" + add_foreign_key "hcb_oauth_connections", "users" + add_foreign_key "hcb_payment_accounts", "hcb_oauth_connections" + add_foreign_key "hcb_payment_accounts", "users" add_foreign_key "letter_queues", "return_addresses", column: "letter_return_address_id" add_foreign_key "letter_queues", "users" add_foreign_key "letter_queues", "usps_mailer_ids", column: "letter_mailer_id_id"