Redirect to the account you joined after sign in

This commit is contained in:
Stanko K.R.
2025-11-04 07:18:02 +01:00
parent fd7a9330e8
commit 5f26690aa1
3 changed files with 68 additions and 2 deletions
+6
View File
@@ -2,6 +2,7 @@ class JoinCodesController < ApplicationController
require_untenanted_access
allow_unauthenticated_access
before_action :set_join_code
before_action :ensure_join_code_is_valid
def new
@account_name = ApplicationRecord.with_tenant(tenant) { Account.sole.name }
@@ -14,10 +15,15 @@ class JoinCodesController < ApplicationController
identity.send_magic_link
end
session[:return_to_after_authenticating] = root_url(script_name: "/#{tenant}")
redirect_to session_magic_link_path
end
private
def ensure_join_code_is_valid
head :not_found unless @join_code&.active?
end
def set_join_code
@join_code ||= ApplicationRecord.with_tenant(tenant) { Account::JoinCode.active.find_by(code: code) }
end