diff --git a/Gemfile.lock b/Gemfile.lock index 16dca130d..bd82778c6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,19 +1,3 @@ -GIT - remote: https://github.com/basecamp/file_repository - revision: 8c8d1594f3ec7e8c0938e6a7f7def521692344e4 - ref: 8c8d1594f3ec7e8c0938e6a7f7def521692344e4 - specs: - file_repository (1.4.6) - -GIT - remote: https://github.com/basecamp/portfolio - revision: 86411a53d19a42ce44705a50ebe7c22828597991 - ref: 86411a53d19a42ce44705a50ebe7c22828597991 - specs: - portfolio (5.2.0) - activesupport - file_repository (>= 1.4.4) - GIT remote: https://github.com/basecamp/queenbee-plugin revision: eb01c697de1ad028afc65cc7d9b5345a7a8e849f @@ -24,16 +8,6 @@ GIT builder rexml -GIT - remote: https://github.com/basecamp/queuety - revision: bf7e2a552fb674533d3e092f06dbf9b5d1ebc753 - ref: bf7e2a552fb674533d3e092f06dbf9b5d1ebc753 - branch: rails4 - specs: - queuety (4.0.2) - activerecord - service_concurrency_prevention - GIT remote: https://github.com/basecamp/rails-structured-logging revision: 76960cb5c15fc2b6b5f7542e05d7dcc031cef9e6 @@ -42,31 +16,6 @@ GIT json rails (>= 6.0.0) -GIT - remote: https://github.com/basecamp/service_concurrency_prevention - revision: 320da99431718615ed86f8723e8b9d3259c602a3 - ref: 320da99431718615ed86f8723e8b9d3259c602a3 - specs: - service_concurrency_prevention (1.1.1) - activesupport - -GIT - remote: https://github.com/basecamp/signal_id - revision: d6c2a5ceed7bb57bf7dcdebdb439e7cd526fca09 - ref: d6c2a5ceed7bb57bf7dcdebdb439e7cd526fca09 - branch: rails4 - specs: - signal_id (4.3.2) - bcrypt-ruby (>= 3.0.0) - google-id-token (>= 1.4.0) - mocha - multi_json - portfolio (>= 4.0) - pwned (~> 2.0) - queuety (>= 3.0) - rails (>= 4.0.2) - rails-controller-testing - GIT remote: https://github.com/crmne/ruby_llm.git revision: 32611afc114c5f40696dd42f8a1eaee6b6b81330 @@ -81,14 +30,6 @@ GIT marcel (~> 1.0) zeitwerk (~> 2) -GIT - remote: https://github.com/jeremy/mysql2.git - revision: b5766f5d296745d6aed014c8c0b7d82ef149ade1 - ref: b5766f5d296745d6aed014c8c0b7d82ef149ade1 - branch: force_latin1_to_utf8 - specs: - mysql2 (0.5.4.latin1utf8) - GIT remote: https://github.com/rails/rails.git revision: d8795bd762ab2716b6e7fd07a403566b28159cdc @@ -206,7 +147,6 @@ PATH queenbee rails (>= 8.1.0.beta1) rails_structured_logging - signal_id GEM remote: https://rubygems.org/ @@ -251,8 +191,6 @@ GEM aws-eventstream (~> 1, >= 1.0.2) base64 (0.3.0) bcrypt (3.1.20) - bcrypt-ruby (3.1.5) - bcrypt (>= 3.1.3) bcrypt_pbkdf (1.1.1) benchmark (0.4.1) bigdecimal (3.2.3) @@ -317,8 +255,6 @@ GEM addressable (>= 2.5.0) globalid (1.2.1) activesupport (>= 6.1) - google-id-token (1.4.2) - jwt (>= 1) hashdiff (1.2.1) i18n (1.14.7) concurrent-ruby (~> 1.0) @@ -391,7 +327,6 @@ GEM mocha (2.7.1) ruby2_keywords (>= 0.0.5) msgpack (1.8.0) - multi_json (1.17.0) multipart-post (2.4.1) net-http (0.6.0) uri @@ -464,7 +399,6 @@ GEM public_suffix (6.0.2) puma (7.0.3) nio4r (~> 2.0) - pwned (2.4.1) raabro (1.4.0) racc (1.8.1) rack (3.2.1) @@ -475,10 +409,6 @@ GEM rack (>= 1.3) rackup (2.2.1) rack (>= 3) - rails-controller-testing (1.0.5) - actionpack (>= 5.0.1.rc1) - actionview (>= 5.0.1.rc1) - activesupport (>= 5.0.1.rc1) rails-dom-testing (2.3.0) activesupport (>= 5.0.0) minitest @@ -670,7 +600,6 @@ DEPENDENCIES bundler-audit capybara debug - file_repository (~> 1.4.5)! fizzy-saas! geared_pagination (~> 1.2) image_processing (~> 1.14) @@ -681,15 +610,12 @@ DEPENDENCIES lexxy mission_control-jobs mocha - mysql2! net-http-persistent platform_agent - portfolio (>= 4.6)! prometheus-client-mmap (~> 1.1) propshaft puma (>= 5.0) queenbee! - queuety! rails! rails_structured_logging! redcarpet @@ -700,8 +626,6 @@ DEPENDENCIES selenium-webdriver sentry-rails sentry-ruby - service_concurrency_prevention! - signal_id! solid_cable (>= 3.0) solid_cache (~> 1.0) solid_queue (~> 1.1) diff --git a/app/models/account.rb b/app/models/account.rb index c29f61005..5ee007e0e 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -3,6 +3,21 @@ class Account < ApplicationRecord has_many_attached :uploads + class << self + def create_with_admin_user(tenant_id:, account_name:, owner_name:, owner_email:) + account = create!(tenant_id:, name: account_name) + + User.create!( + name: owner_name, + email_address: owner_email, + role: "admin", + password: SecureRandom.hex(16) + ) + + account + end + end + def slug "/#{tenant}" end diff --git a/bin/setup b/bin/setup index 329858c5b..f1407fb90 100755 --- a/bin/setup +++ b/bin/setup @@ -15,9 +15,7 @@ load File.expand_path("../gems/fizzy-saas/bin/setup", __dir__) unless Bootstrap. puts "\n== Preparing database ==" if ARGV.include?("--reset") - system! "bin/rails db:drop db:create db:schema:load db:prepare" - system! "bin/rails db:fixtures:load" # load signal id fixtures before running fizzy seeds - system! "bin/rails db:seed" + system! "bin/rails db:drop db:create db:schema:load db:prepare db:seed" else system! "bin/rails db:prepare" end diff --git a/config/ci.rb b/config/ci.rb index 304d4cd49..be81c58c9 100644 --- a/config/ci.rb +++ b/config/ci.rb @@ -11,7 +11,6 @@ CI.run do step "Tests: Rails: SaaS config", "bin/rails test" step "Tests: Rails: OSS config", "OSS_CONFIG=1 bin/rails test" - step "Tests: 37id", "bin/rails 37id:test:units" step "Tests: System", "bin/rails test:system" if success? diff --git a/db/migrate/20251001181713_remove_external_user_id_from_users.rb b/db/migrate/20251001181713_remove_external_user_id_from_users.rb new file mode 100644 index 000000000..ffd0a240a --- /dev/null +++ b/db/migrate/20251001181713_remove_external_user_id_from_users.rb @@ -0,0 +1,5 @@ +class RemoveExternalUserIdFromUsers < ActiveRecord::Migration[8.1] + def change + remove_column :users, :external_user_id, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 1ead0bdad..5e2c6ac59 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.1].define(version: 2025_09_24_124737) do +ActiveRecord::Schema[8.1].define(version: 2025_10_01_181713) do create_table "accesses", force: :cascade do |t| t.datetime "accessed_at" t.integer "collection_id", null: false @@ -451,13 +451,11 @@ ActiveRecord::Schema[8.1].define(version: 2025_09_24_124737) do t.boolean "active", default: true, null: false t.datetime "created_at", null: false t.string "email_address" - t.integer "external_user_id" t.string "name", null: false t.string "password_digest" t.string "role", default: "member", null: false t.datetime "updated_at", null: false t.index ["email_address"], name: "index_users_on_email_address", unique: true - t.index ["external_user_id"], name: "index_users_on_external_user_id", unique: true t.index ["role"], name: "index_users_on_role" end diff --git a/db/schema_cache.yml b/db/schema_cache.yml index 44cbe56d9..074393719 100644 --- a/db/schema_cache.yml +++ b/db/schema_cache.yml @@ -1290,16 +1290,6 @@ columns: default_function: collation: comment: - - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column - auto_increment: - name: external_user_id - cast_type: *3 - sql_type_metadata: *4 - 'null': true - default: - default_function: - collation: - comment: - *6 - *10 - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column @@ -3098,22 +3088,6 @@ indexes: nulls_not_distinct: comment: valid: true - - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition - table: users - name: index_users_on_external_user_id - unique: true - columns: - - external_user_id - lengths: {} - orders: {} - opclasses: {} - where: - type: - using: - include: - nulls_not_distinct: - comment: - valid: true - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition table: users name: index_users_on_role @@ -3248,4 +3222,4 @@ indexes: comment: valid: true workflows: [] -version: 20250924124737 +version: 20251001181713 diff --git a/db/seeds.rb b/db/seeds.rb index 32532d258..5542dd3d1 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -13,26 +13,18 @@ end def create_tenant(signal_account_name, bare: false) if bare tenant_id = Digest::SHA256.hexdigest(signal_account_name)[0..8].to_i(16) - elsif Rails.application.config.x.oss_config - tenant_id = ActiveRecord::FixtureSet.identify signal_account_name else - signal_account = SignalId::Account.find_by_product_and_name!("fizzy", signal_account_name) - tenant_id = signal_account.queenbee_id + tenant_id = ActiveRecord::FixtureSet.identify signal_account_name end ApplicationRecord.destroy_tenant tenant_id ApplicationRecord.create_tenant(tenant_id) do - account = if bare || Rails.application.config.x.oss_config - Account.create(name: signal_account_name, tenant_id: tenant_id).tap do - User.create!( - name: "David Heinemeier Hansson", - email_address: "david@37signals.com", - password: "secret123456" - ) - end - else - Account.create_with_admin_user(tenant_id: tenant_id) - end + account = Account.create_with_admin_user( + tenant_id: tenant_id, + account_name: signal_account_name, + owner_name: "David Heinemeier Hansson", + owner_email: "david@37signals.com", + ) account.setup_basic_template end diff --git a/gems/fizzy-saas/Gemfile b/gems/fizzy-saas/Gemfile index 9f8dfd669..396a3192e 100644 --- a/gems/fizzy-saas/Gemfile +++ b/gems/fizzy-saas/Gemfile @@ -2,11 +2,5 @@ source "https://rubygems.org" git_source(:bc) { |repo| "https://github.com/basecamp/#{repo}" } # 37id and Queenbee integration -gem "signal_id", bc: "signal_id", branch: "rails4", ref: "d6c2a5ceed7bb57bf7dcdebdb439e7cd526fca09" -gem "mysql2", github: "jeremy/mysql2", branch: "force_latin1_to_utf8", ref: "b5766f5d296745d6aed014c8c0b7d82ef149ade1" # needed by signal_id -gem "queuety", bc: "queuety", branch: "rails4", ref: "bf7e2a552fb674533d3e092f06dbf9b5d1ebc753" # needed by signal_id -gem "service_concurrency_prevention", bc: "service_concurrency_prevention", ref: "320da99431718615ed86f8723e8b9d3259c602a3" # needed by queuety -gem "portfolio", ">= 4.6", bc: "portfolio", ref: "86411a53d19a42ce44705a50ebe7c22828597991" # needed by signal_id -gem "file_repository", "~> 1.4.5", bc: "file_repository", ref: "8c8d1594f3ec7e8c0938e6a7f7def521692344e4" # needed by portfolio gem "queenbee", bc: "queenbee-plugin", ref: "eb01c697de1ad028afc65cc7d9b5345a7a8e849f" gem "activeresource", require: "active_resource" # needed by queenbee diff --git a/gems/fizzy-saas/Gemfile.lock b/gems/fizzy-saas/Gemfile.lock index f5c6c0ef5..5d83987cd 100644 --- a/gems/fizzy-saas/Gemfile.lock +++ b/gems/fizzy-saas/Gemfile.lock @@ -1,19 +1,3 @@ -GIT - remote: https://github.com/basecamp/file_repository - revision: 8c8d1594f3ec7e8c0938e6a7f7def521692344e4 - ref: 8c8d1594f3ec7e8c0938e6a7f7def521692344e4 - specs: - file_repository (1.4.6) - -GIT - remote: https://github.com/basecamp/portfolio - revision: 86411a53d19a42ce44705a50ebe7c22828597991 - ref: 86411a53d19a42ce44705a50ebe7c22828597991 - specs: - portfolio (5.2.0) - activesupport - file_repository (>= 1.4.4) - GIT remote: https://github.com/basecamp/queenbee-plugin revision: eb01c697de1ad028afc65cc7d9b5345a7a8e849f @@ -24,118 +8,19 @@ GIT builder rexml -GIT - remote: https://github.com/basecamp/queuety - revision: bf7e2a552fb674533d3e092f06dbf9b5d1ebc753 - ref: bf7e2a552fb674533d3e092f06dbf9b5d1ebc753 - branch: rails4 - specs: - queuety (4.0.2) - activerecord - service_concurrency_prevention - -GIT - remote: https://github.com/basecamp/service_concurrency_prevention - revision: 320da99431718615ed86f8723e8b9d3259c602a3 - ref: 320da99431718615ed86f8723e8b9d3259c602a3 - specs: - service_concurrency_prevention (1.1.1) - activesupport - -GIT - remote: https://github.com/basecamp/signal_id - revision: d6c2a5ceed7bb57bf7dcdebdb439e7cd526fca09 - ref: d6c2a5ceed7bb57bf7dcdebdb439e7cd526fca09 - branch: rails4 - specs: - signal_id (4.3.2) - bcrypt-ruby (>= 3.0.0) - google-id-token (>= 1.4.0) - mocha - multi_json - portfolio (>= 4.0) - pwned (~> 2.0) - queuety (>= 3.0) - rails (>= 4.0.2) - rails-controller-testing - -GIT - remote: https://github.com/jeremy/mysql2.git - revision: b5766f5d296745d6aed014c8c0b7d82ef149ade1 - ref: b5766f5d296745d6aed014c8c0b7d82ef149ade1 - branch: force_latin1_to_utf8 - specs: - mysql2 (0.5.4.latin1utf8) - GEM remote: https://rubygems.org/ specs: - actioncable (8.0.2.1) - actionpack (= 8.0.2.1) - activesupport (= 8.0.2.1) - nio4r (~> 2.0) - websocket-driver (>= 0.6.1) - zeitwerk (~> 2.6) - actionmailbox (8.0.2.1) - actionpack (= 8.0.2.1) - activejob (= 8.0.2.1) - activerecord (= 8.0.2.1) - activestorage (= 8.0.2.1) - activesupport (= 8.0.2.1) - mail (>= 2.8.0) - actionmailer (8.0.2.1) - actionpack (= 8.0.2.1) - actionview (= 8.0.2.1) - activejob (= 8.0.2.1) - activesupport (= 8.0.2.1) - mail (>= 2.8.0) - rails-dom-testing (~> 2.2) - actionpack (8.0.2.1) - actionview (= 8.0.2.1) - activesupport (= 8.0.2.1) - nokogiri (>= 1.8.5) - rack (>= 2.2.4) - rack-session (>= 1.0.1) - rack-test (>= 0.6.3) - rails-dom-testing (~> 2.2) - rails-html-sanitizer (~> 1.6) - useragent (~> 0.16) - actiontext (8.0.2.1) - actionpack (= 8.0.2.1) - activerecord (= 8.0.2.1) - activestorage (= 8.0.2.1) - activesupport (= 8.0.2.1) - globalid (>= 0.6.0) - nokogiri (>= 1.8.5) - actionview (8.0.2.1) - activesupport (= 8.0.2.1) - builder (~> 3.1) - erubi (~> 1.11) - rails-dom-testing (~> 2.2) - rails-html-sanitizer (~> 1.6) - activejob (8.0.2.1) - activesupport (= 8.0.2.1) - globalid (>= 0.3.6) activemodel (8.0.2.1) activesupport (= 8.0.2.1) activemodel-serializers-xml (1.0.3) activemodel (>= 5.0.0.a) activesupport (>= 5.0.0.a) builder (~> 3.1) - activerecord (8.0.2.1) - activemodel (= 8.0.2.1) - activesupport (= 8.0.2.1) - timeout (>= 0.4.0) activeresource (6.1.4) activemodel (>= 6.0) activemodel-serializers-xml (~> 1.0) activesupport (>= 6.0) - activestorage (8.0.2.1) - actionpack (= 8.0.2.1) - activejob (= 8.0.2.1) - activerecord (= 8.0.2.1) - activesupport (= 8.0.2.1) - marcel (~> 1.0) activesupport (8.0.2.1) base64 benchmark (>= 0.3) @@ -150,143 +35,21 @@ GEM tzinfo (~> 2.0, >= 2.0.5) uri (>= 0.13.1) base64 (0.3.0) - bcrypt (3.1.20) - bcrypt-ruby (3.1.5) - bcrypt (>= 3.1.3) benchmark (0.4.1) bigdecimal (3.2.3) builder (3.3.0) concurrent-ruby (1.3.5) connection_pool (2.5.4) - crass (1.0.6) - date (3.4.1) drb (2.2.3) - erb (5.0.2) - erubi (1.13.1) - globalid (1.2.1) - activesupport (>= 6.1) - google-id-token (1.4.2) - jwt (>= 1) i18n (1.14.7) concurrent-ruby (~> 1.0) - io-console (0.8.1) - irb (1.15.2) - pp (>= 0.6.0) - rdoc (>= 4.0.0) - reline (>= 0.4.2) - jwt (3.1.2) - base64 logger (1.7.0) - loofah (2.24.1) - crass (~> 1.0.2) - nokogiri (>= 1.12.0) - mail (2.8.1) - mini_mime (>= 0.1.1) - net-imap - net-pop - net-smtp - marcel (1.0.4) - mini_mime (1.1.5) minitest (5.25.5) - mocha (2.7.1) - ruby2_keywords (>= 0.0.5) - multi_json (1.17.0) - net-imap (0.5.10) - date - net-protocol - net-pop (0.1.2) - net-protocol - net-protocol (0.2.2) - timeout - net-smtp (0.5.1) - net-protocol - nio4r (2.7.4) - nokogiri (1.18.9-aarch64-linux-gnu) - racc (~> 1.4) - nokogiri (1.18.9-aarch64-linux-musl) - racc (~> 1.4) - nokogiri (1.18.9-arm-linux-gnu) - racc (~> 1.4) - nokogiri (1.18.9-arm-linux-musl) - racc (~> 1.4) - nokogiri (1.18.9-arm64-darwin) - racc (~> 1.4) - nokogiri (1.18.9-x86_64-darwin) - racc (~> 1.4) - nokogiri (1.18.9-x86_64-linux-gnu) - racc (~> 1.4) - nokogiri (1.18.9-x86_64-linux-musl) - racc (~> 1.4) - pp (0.6.2) - prettyprint - prettyprint (0.2.0) - psych (5.2.6) - date - stringio - pwned (2.4.1) - racc (1.8.1) - rack (3.2.1) - rack-session (2.1.1) - base64 (>= 0.1.0) - rack (>= 3.0.0) - rack-test (2.2.0) - rack (>= 1.3) - rackup (2.2.1) - rack (>= 3) - rails (8.0.2.1) - actioncable (= 8.0.2.1) - actionmailbox (= 8.0.2.1) - actionmailer (= 8.0.2.1) - actionpack (= 8.0.2.1) - actiontext (= 8.0.2.1) - actionview (= 8.0.2.1) - activejob (= 8.0.2.1) - activemodel (= 8.0.2.1) - activerecord (= 8.0.2.1) - activestorage (= 8.0.2.1) - activesupport (= 8.0.2.1) - bundler (>= 1.15.0) - railties (= 8.0.2.1) - rails-controller-testing (1.0.5) - actionpack (>= 5.0.1.rc1) - actionview (>= 5.0.1.rc1) - activesupport (>= 5.0.1.rc1) - rails-dom-testing (2.3.0) - activesupport (>= 5.0.0) - minitest - nokogiri (>= 1.6) - rails-html-sanitizer (1.6.2) - loofah (~> 2.21) - nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) - railties (8.0.2.1) - actionpack (= 8.0.2.1) - activesupport (= 8.0.2.1) - irb (~> 1.13) - rackup (>= 1.0.0) - rake (>= 12.2) - thor (~> 1.0, >= 1.2.2) - zeitwerk (~> 2.6) - rake (13.3.0) - rdoc (6.14.2) - erb - psych (>= 4.0.0) - reline (0.6.2) - io-console (~> 0.5) rexml (3.4.4) - ruby2_keywords (0.0.5) securerandom (0.4.1) - stringio (3.1.7) - thor (1.4.0) - timeout (0.4.3) tzinfo (2.0.6) concurrent-ruby (~> 1.0) uri (1.0.3) - useragent (0.16.11) - websocket-driver (0.8.0) - base64 - websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.5) - zeitwerk (2.7.3) PLATFORMS aarch64-linux-gnu @@ -300,13 +63,7 @@ PLATFORMS DEPENDENCIES activeresource - file_repository (~> 1.4.5)! - mysql2! - portfolio (>= 4.6)! queenbee! - queuety! - service_concurrency_prevention! - signal_id! BUNDLED WITH 2.7.0 diff --git a/gems/fizzy-saas/app/controllers/signup/accounts_controller.rb b/gems/fizzy-saas/app/controllers/signup/accounts_controller.rb deleted file mode 100644 index f61baa289..000000000 --- a/gems/fizzy-saas/app/controllers/signup/accounts_controller.rb +++ /dev/null @@ -1,30 +0,0 @@ -class Signup::AccountsController < Signup::BaseController - before_action :reset_signup_storage - rate_limit to: 10, within: 3.minutes, only: :create, with: -> { redirect_to saas.new_signup_account_path, alert: "Try again later." } - - def new - @signup = Signup.new - end - - def create - @signup = Signup.new(signup_params) - - if @signup.recognized? - store_signup - redirect_to Launchpad.authentication_url(purpose: "signup", login_hint: @signup.email_address, redirect_uri: saas.signup_session_url), allow_other_host: true - elsif @signup.process - redirect_to_account(@signup.account) - else - render :new, status: :unprocessable_entity - end - end - - private - def signup_params - params.require(:signup).permit(*Signup::PERMITTED_KEYS) - end - - def store_signup - @signup.to_h.each { |key, value| signup_storage[key.to_s] = value } - end -end diff --git a/gems/fizzy-saas/app/controllers/signup/base_controller.rb b/gems/fizzy-saas/app/controllers/signup/base_controller.rb deleted file mode 100644 index ed884fffa..000000000 --- a/gems/fizzy-saas/app/controllers/signup/base_controller.rb +++ /dev/null @@ -1,36 +0,0 @@ -class Signup::BaseController < ApplicationController - require_untenanted_access - - # TODO: Remove this auth before launch. - http_basic_authenticate_with( - name: Rails.env.test? ? "testname" : Rails.application.credentials.account_signup_http_basic_auth.name, - password: Rails.env.test? ? "testpassword" : Rails.application.credentials.account_signup_http_basic_auth.password - ) - - attr_reader :authenticated_identity - - private - def signup_storage - session[:signup] ||= {} - end - - def reset_signup_storage - session.delete(:signup) - end - - def authenticated_identity=(identity) - @authenticated_identity = identity - signup_storage["identity_id"] = identity.try(:id) - end - - def set_authenticated_identity - if identity_id = signup_storage["identity_id"] - @authenticated_identity = SignalId::Identity.find_by(id: identity_id) - end - end - - def redirect_to_account(account) - redirect_to account.external_account.owner.remote_login_url(proceed_to: root_path), - allow_other_host: true - end -end diff --git a/gems/fizzy-saas/app/controllers/signup/completions_controller.rb b/gems/fizzy-saas/app/controllers/signup/completions_controller.rb deleted file mode 100644 index 4f97055a0..000000000 --- a/gems/fizzy-saas/app/controllers/signup/completions_controller.rb +++ /dev/null @@ -1,23 +0,0 @@ -class Signup::CompletionsController < Signup::BaseController - before_action :set_authenticated_identity, only: :create - - def new - end - - def create - @signup = Signup.new(signup_params) - @signup.signal_identity = authenticated_identity - - if @signup.process - reset_signup_storage - redirect_to_account(@signup.account) - else - render plain: "Could not complete signup. This is probably a bug.", status: :unprocessable_entity, layout: false - end - end - - private - def signup_params - signup_storage.slice(*Signup::PERMITTED_KEYS.map(&:to_s)) - end -end diff --git a/gems/fizzy-saas/app/controllers/signup/sessions_controller.rb b/gems/fizzy-saas/app/controllers/signup/sessions_controller.rb deleted file mode 100644 index 20ab7c2c0..000000000 --- a/gems/fizzy-saas/app/controllers/signup/sessions_controller.rb +++ /dev/null @@ -1,9 +0,0 @@ -class Signup::SessionsController < Signup::BaseController - def create - if self.authenticated_identity = SignalId::Identity.authenticate(params.permit(:sig)) - redirect_to saas.new_signup_completion_url - else - render plain: "Authentication failed. This is probably a bug.", status: :unauthorized - end - end -end diff --git a/gems/fizzy-saas/app/models/account/signal_account.rb b/gems/fizzy-saas/app/models/account/signal_account.rb deleted file mode 100644 index f117347dd..000000000 --- a/gems/fizzy-saas/app/models/account/signal_account.rb +++ /dev/null @@ -1,30 +0,0 @@ -module Account::SignalAccount - extend ActiveSupport::Concern - - prepended do - # the tenant_id column is the SignalId::Account's queenbee_id - belongs_to :external_account, class_name: "SignalId::Account", primary_key: :queenbee_id, foreign_key: :tenant_id, optional: true - end - - class_methods do - def find_by_queenbee_id(queenbee_id) - find_by(tenant_id: queenbee_id) - end - - def create_with_admin_user(tenant_id:) - new(tenant_id:).tap do |account| - SignalId::Database.on_master do - account.name = account.external_account.name - account.save! - - User.create!( - name: account.external_account.owner.name, - email_address: account.external_account.owner.email_address, - role: "admin", - password: SecureRandom.hex(16) - ) - end - end - end - end -end diff --git a/gems/fizzy-saas/app/models/launchpad.rb b/gems/fizzy-saas/app/models/launchpad.rb deleted file mode 100644 index 268d6e1d1..000000000 --- a/gems/fizzy-saas/app/models/launchpad.rb +++ /dev/null @@ -1,24 +0,0 @@ -# lifted from bc3 app/models/launchpad.rb -module Launchpad - extend self - - delegate :url, to: "SignalId.launchpad" - - def login_url(product: false, account: nil, **params) - url product_account_path("/signin", product: product, account: account), params - end - - def logout_url - url "/signout" - end - - def authentication_url(**params) - url "/authenticate", params.merge(product: :fizzy) - end - - def product_account_path(path = nil, product: false, account: nil) - product_path = "/fizzy" if product || account - account_path = "/#{account.external_account.id}" if account - [ product_path, account_path, path ].compact.join - end -end diff --git a/gems/fizzy-saas/app/models/signup.rb b/gems/fizzy-saas/app/models/signup.rb deleted file mode 100644 index 7e3d54531..000000000 --- a/gems/fizzy-saas/app/models/signup.rb +++ /dev/null @@ -1,159 +0,0 @@ -class Signup - include ActiveModel::Model - include ActiveModel::Attributes - include ActiveModel::Validations - - PERMITTED_KEYS = %i[ full_name email_address password company_name ] - - # Input attribute - attr_accessor :company_name - - # Input attributes when not using an existing identity - attr_accessor :full_name, :email_address, :password - - # Input attribute when using an existing identity, output when creating new identity - attr_accessor :signal_identity - - # Output attributes - attr_reader :queenbee_account, :signal_account, :account, :user - - validate :validate_new_identity - - def initialize(...) - @full_name = nil - @email_address = nil - @password = nil - @company_name = nil - @signal_identity = nil - @queenbee_account = nil - @account = nil - @user = nil - - super - end - - def process(destroy_existing_tenant: false) - return false unless valid? - - create_signal_identity - create_queenbee_account - create_tenant(destroy_existing_tenant:) - - true - rescue => error - destroy_tenant - destroy_queenbee_account - destroy_signal_identity - - errors.add(:base, "An error occurred during signup: #{error.message}") - - false - end - - def recognized? - SignalId::Identity.find_by_email_address(email_address).present? - end - - def tenant_name - @tenant_name ||= @queenbee_account.id.to_s - end - - def to_h - { - full_name: full_name, - email_address: email_address, - company_name: company_name - }.compact_blank - end - - private - def create_signal_identity - unless signal_identity.present? - SignalId::Database.on_master do - @signal_identity = build_new_identity.tap(&:save!) - end - end - end - - def create_queenbee_account - @queenbee_account = Queenbee::Remote::Account.create!(queenbee_account_attributes) - SignalId::Database.on_master do - @signal_account = SignalId::Account.find_by(queenbee_id: @queenbee_account.id) - end - end - - def create_tenant(destroy_existing_tenant: false, &block) - ApplicationRecord.destroy_tenant(tenant_name) if destroy_existing_tenant - ApplicationRecord.create_tenant(tenant_name) do - @account = Account.create_with_admin_user(tenant_id: queenbee_account.id) - @account.setup_basic_template - @user = User.first - end - end - - def destroy_tenant - if queenbee_account && ApplicationRecord.tenant_exist?(tenant_name) - ApplicationRecord.destroy_tenant(tenant_name) - @account = nil - @user = nil - end - end - - def destroy_queenbee_account - queenbee_account&.cancel - @queenbee_account = nil - end - - def destroy_signal_identity - SignalId::Database.on_master do - signal_identity&.destroy - end - @signal_identity = nil - end - - def validate_new_identity - unless signal_identity.present? - build_new_identity.tap do |identity| - unless identity.valid? - identity.errors.each { |error| errors.add(error.attribute, error.message) } - end - end - end - end - - def build_new_identity - SignalId::Identity.new do |identity| - identity.name = full_name || email_address - identity.email_address = email_address - identity.username = email_address - identity.password = password - end - end - - def queenbee_account_attributes - { - skip_remote: true, # Fizzy creates its own local account - product_name: "fizzy", - name: queenbee_account_name, - owner_identity_id: signal_identity.id, - trial: false, - subscription: subscription_attributes, - remote_request: request_attributes - } - end - - def subscription_attributes - subscription = FreeV1Subscription - { name: subscription.to_param, price: subscription.price } - end - - def request_attributes - { remote_address: Current.ip_address, user_agent: Current.user_agent, referrer: Current.referrer } - end - - def queenbee_account_name - name = company_name.presence || signal_identity.name - name += " (Beta)" if Rails.env.beta? - name - end -end diff --git a/gems/fizzy-saas/app/views/sessions/launchpad/show.html.erb b/gems/fizzy-saas/app/views/sessions/launchpad/show.html.erb deleted file mode 100644 index 077cb5b42..000000000 --- a/gems/fizzy-saas/app/views/sessions/launchpad/show.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -<%= auto_submit_form_with(method: :put, url: saas.session_launchpad_path) do |form| %> - <%= form.hidden_field(:sig, value: @sig) %> -<% end %> diff --git a/gems/fizzy-saas/app/views/signup/accounts/new.html.erb b/gems/fizzy-saas/app/views/signup/accounts/new.html.erb deleted file mode 100644 index 6ddba7c36..000000000 --- a/gems/fizzy-saas/app/views/signup/accounts/new.html.erb +++ /dev/null @@ -1,58 +0,0 @@ -<% @page_title = "Sign up for Fizzy" %> - -