Delete SignalId concerns from the codebase

including Signup for now, will rebuild it with just QB
This commit is contained in:
Mike Dalessio
2025-10-03 13:35:36 -04:00
parent b93a32a57f
commit 8e0cb930af
28 changed files with 61 additions and 1239 deletions
@@ -1,53 +0,0 @@
#!/usr/bin/env ruby
#
# set up a temporary password for all users
# while we migrate away from Launchpad and 37id.
#
# the password is unguessable but generated based on the email address and a seed,
# so each user will have the same password across all tenants.
#
require_relative "../../config/environment"
seed = ARGV[0] || "temporary-password-seed"
puts "Using seed: #{seed.inspect}"
TENANTS = Hash.new
USERS = Hash.new { |h, k| h[k] = Hash.new }
ApplicationRecord.with_each_tenant do |tenant|
TENANTS[tenant] = Account.sole.name
User.find_each do |user|
putc "."
next if user.system?
if user.external_user_id
suser = SignalId::User.find_by_id(user.external_user_id)
if suser && suser.email_address != user.email_address
puts "\nWarning: fixing email address for user #{user.id} in tenant #{tenant}:"
puts " local: #{user.email_address}"
puts " signal: #{suser.email_address}"
user.update! email_address: suser.email_address
end
end
password = Digest::SHA256.hexdigest("#{seed}-#{user.email_address}")[0..16]
user.update! password: password
USERS[user.email_address][tenant] = password
end
end
puts
USERS.each do |email, hash|
puts "\n#{email}:"
puts " password: #{hash.first.last}"
puts " fizzies:"
hash.each do |tenant, _|
url = Rails.application.routes.url_helpers.root_url(Rails.application.config.action_controller.default_url_options.merge(script_name: "/#{tenant}"))
puts " #{TENANTS[tenant]}: #{url}"
end
end
-117
View File
@@ -1,117 +0,0 @@
#!/usr/bin/env ruby
require_relative "../config/environment"
ActiveRecord::Base.logger = Logger.new(File::NULL)
class BootstrapSignalId
def initialize(dry_run: false)
@dry_run = dry_run
end
def run
SignalId::Database.on_master do
ApplicationRecord.with_each_tenant do |tenant|
puts "\n# tenant: #{tenant}"
next unless check_account_preconditions
create_signal_id_account if Account.sole.queenbee_id.nil?
create_signal_id_users
end
end
end
def check_account_preconditions
unless Account.count == 1
puts "There are #{Account.count} accounts, but exactly one is expected."
false
else
true
end
end
def create_signal_id_account
owner = SignalId::Identity.find_by_email_address!("kevin@37signals.com")
print_identity("New owner is:", owner)
unless @dry_run
qbattr = queenbee_account_attributes(owner)
queenbee_account = Queenbee::Remote::Account.create!(qbattr)
signal_id_account = SignalId::Account.find_by!(queenbee_id: queenbee_account.id)
signal_id_account.update_column :subdomain, ApplicationRecord.current_tenant
account = Account.sole
account.queenbee_id = queenbee_account.id
account.name = ApplicationRecord.current_tenant
account.save!
end
end
def create_signal_id_users
signal_account = Account.sole.signal_account
User.find_each do |user|
if !user.system? && user.signal_user_id.nil?
signal_identities = SignalId::Identity.where(email_address: user.email_address)
if signal_identities.length > 1
puts "Multiple identities found for #{user.email_address}:"
signal_identities.each { |identity| print_identity(" - ", identity) }
signal_identity = signal_identities.first
elsif signal_identities.length == 1
signal_identity = signal_identities.first
print_identity("Identity for #{user.email_address}:", signal_identity)
else
puts "No identity found for #{user.name} (#{user.email_address})"
signal_identity = nil
end
if signal_identity
unless @dry_run
signal_user = SignalId::User.find_or_create_by!(identity: signal_identity, account: signal_account)
user.signal_user_id = signal_user.id
user.save!
end
end
end
end
end
def print_identity(message = "Identity:", identity)
pad = " " * message.length
puts "#{message} #{identity.name} (#{identity.email_address})"
puts "#{pad } ID: #{identity.id}"
puts "#{pad } Username: #{identity.username}"
end
def queenbee_account_attributes(signal_identity)
{
skip_remote: true, # Fizzy creates its own local account
product_name: "fizzy",
name: 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
{ user_agent: "script/bootstrap-signal-id.rb" }
end
def account_name
name = ApplicationRecord.current_tenant
name += " (Beta)" if Rails.env.beta?
name
end
end
BootstrapSignalId.new(dry_run: false).run