Merge pull request #772 from basecamp/flavorjones/unwind-current-account
Drop Current.account and just use Account.sole
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
/tmp/*
|
||||
!/log/.keep
|
||||
!/tmp/.keep
|
||||
*.log
|
||||
|
||||
# Ignore pidfiles, but keep the directory.
|
||||
/tmp/pids/*
|
||||
@@ -28,6 +29,7 @@
|
||||
/tmp/storage/*
|
||||
!/tmp/storage/
|
||||
!/tmp/storage/.keep
|
||||
/data
|
||||
|
||||
/public/assets
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ module Authentication
|
||||
# Checking for tenant must happen first so we redirect before trying to access the db.
|
||||
before_action :require_tenant
|
||||
|
||||
before_action :set_current_account
|
||||
before_action :require_authentication
|
||||
helper_method :authenticated?
|
||||
end
|
||||
@@ -23,7 +22,6 @@ module Authentication
|
||||
|
||||
def require_untenanted_access(**options)
|
||||
skip_before_action :require_tenant, **options
|
||||
skip_before_action :set_current_account, **options
|
||||
skip_before_action :require_authentication, **options
|
||||
before_action :redirect_tenanted_request, **options
|
||||
end
|
||||
@@ -52,11 +50,14 @@ module Authentication
|
||||
Session.find_signed(cookies.signed[:session_token])
|
||||
end
|
||||
|
||||
|
||||
def request_authentication
|
||||
session[:return_to_after_authenticating] = request.url
|
||||
|
||||
redirect_to Launchpad.login_url(product: true, account: Current.account), allow_other_host: true
|
||||
def request_authentication(untenanted: false)
|
||||
if ApplicationRecord.current_tenant.present?
|
||||
session[:return_to_after_authenticating] = request.url
|
||||
redirect_to Launchpad.login_url(product: true, account: Account.sole), allow_other_host: true
|
||||
else
|
||||
# Don't save the current untenanted URL, because it's just going to bounce back to Launchpad after login anyway.
|
||||
redirect_to Launchpad.login_url(product: true), allow_other_host: true
|
||||
end
|
||||
end
|
||||
|
||||
def after_authentication_url
|
||||
@@ -83,10 +84,6 @@ module Authentication
|
||||
cookies.signed.permanent[:session_token] = { value: session.signed_id, httponly: true, same_site: :lax }
|
||||
end
|
||||
|
||||
def set_current_account
|
||||
Current.account = Account.first
|
||||
end
|
||||
|
||||
def terminate_session
|
||||
Current.session.destroy
|
||||
cookies.delete(:session_token)
|
||||
|
||||
@@ -7,7 +7,7 @@ class Sessions::LaunchpadController < ApplicationController
|
||||
end
|
||||
|
||||
def update
|
||||
user = Current.account.signal_account.authenticate(sig: @sig).try(:peer)
|
||||
user = Account.sole.signal_account.authenticate(sig: @sig).try(:peer)
|
||||
if user.present? && user.active?
|
||||
start_new_session_for user
|
||||
redirect_to after_authentication_url
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
class Current < ActiveSupport::CurrentAttributes
|
||||
attribute :session
|
||||
attribute :http_method, :request_id, :user_agent, :ip_address, :referrer
|
||||
attribute :account
|
||||
|
||||
delegate :user, to: :session, allow_nil: true
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<nav class="header">
|
||||
<div class="header__actions header__actions--start"></div>
|
||||
<div class="header__actions header__actions--end">
|
||||
<%= link_to Launchpad.login_url(account: Current.account), class: "btn", data: { controller: "hotkey", action: "keydown.esc@document->hotkey#click" } do %>
|
||||
<%= link_to Launchpad.login_url(account: Account.sole), class: "btn", data: { controller: "hotkey", action: "keydown.esc@document->hotkey#click" } do %>
|
||||
<span class="for-screen-reader">Sign in instead</span>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ def find_or_create_user(full_name, email_address)
|
||||
)
|
||||
end
|
||||
|
||||
signal_account = Account.first.signal_account
|
||||
signal_account = Account.sole.signal_account
|
||||
signal_user = SignalId::User.find_or_create_by!(identity: signal_identity, account: signal_account)
|
||||
|
||||
if user = User.find_by(signal_user_id: signal_user.id)
|
||||
|
||||
@@ -15,7 +15,7 @@ class BootstrapSignalId
|
||||
puts "\n# tenant: #{tenant}"
|
||||
|
||||
next unless check_account_preconditions
|
||||
create_signal_id_account if Account.first.queenbee_id.nil?
|
||||
create_signal_id_account if Account.sole.queenbee_id.nil?
|
||||
|
||||
create_signal_id_users
|
||||
end
|
||||
@@ -42,7 +42,7 @@ class BootstrapSignalId
|
||||
signal_id_account = SignalId::Account.find_by!(queenbee_id: queenbee_account.id)
|
||||
signal_id_account.update_column :subdomain, ApplicationRecord.current_tenant
|
||||
|
||||
account = Account.first
|
||||
account = Account.sole
|
||||
account.queenbee_id = queenbee_account.id
|
||||
account.name = ApplicationRecord.current_tenant
|
||||
account.save!
|
||||
@@ -50,7 +50,7 @@ class BootstrapSignalId
|
||||
end
|
||||
|
||||
def create_signal_id_users
|
||||
signal_account = Account.first.signal_account
|
||||
signal_account = Account.sole.signal_account
|
||||
|
||||
User.find_each do |user|
|
||||
if !user.system? && user.signal_user_id.nil?
|
||||
|
||||
@@ -4,7 +4,7 @@ COLLECTIONS_COUNT = 100
|
||||
CARDS_PER_COLLECTION = 50
|
||||
|
||||
ApplicationRecord.current_tenant = "development-tenant"
|
||||
account = Account.first
|
||||
account = Account.sole
|
||||
user = account.users.first
|
||||
Current.session = user.sessions.last
|
||||
workflow = account.workflows.first
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
require_relative "../config/environment"
|
||||
|
||||
ApplicationRecord.with_each_tenant do |tenant|
|
||||
account = Account.first
|
||||
account = Account.sole
|
||||
signal_account = account.signal_account
|
||||
|
||||
signal_users = SignalId::User.where(account_id: signal_account.id)
|
||||
|
||||
@@ -25,7 +25,7 @@ def fix_attachments(rich_text)
|
||||
end
|
||||
|
||||
ApplicationRecord.with_each_tenant do |tenant|
|
||||
account_id = Account.first.queenbee_id
|
||||
account_id = Account.sole.queenbee_id
|
||||
|
||||
unless account_id
|
||||
puts "Skipping URL fixup for tenant: #{tenant}"
|
||||
@@ -37,7 +37,7 @@ ApplicationRecord.with_each_tenant do |tenant|
|
||||
domain = domains[Rails.env] || domains["production"]
|
||||
regex = %r{://\w+\.#{domain}/}
|
||||
|
||||
pp [ Account.first.name, account_id, domain, regex ]
|
||||
pp [ Account.sole.name, account_id, domain, regex ]
|
||||
puts
|
||||
|
||||
Card.find_each do |card|
|
||||
|
||||
@@ -3,7 +3,7 @@ require_relative "../../config/environment"
|
||||
CARDS_COUNT = 200
|
||||
|
||||
ApplicationRecord.current_tenant = "37signals"
|
||||
account = Account.first
|
||||
account = Account.sole
|
||||
user = User.first
|
||||
Current.session = user.sessions.last
|
||||
collection = Collection.first
|
||||
|
||||
@@ -7,7 +7,7 @@ tenant_names = []
|
||||
ApplicationRecord.with_each_tenant do |tenant|
|
||||
next if tenant == "#{Rails.env}-tenant"
|
||||
|
||||
account = Account.first
|
||||
account = Account.sole
|
||||
queenbee_id = account.queenbee_id
|
||||
tenant_names << { from: tenant, to: queenbee_id }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user