Files
fizzy/app/controllers/join_codes_controller.rb
T
Stanko Krtalić 98755844a1 Remove the internal API
* Bind sessions to identities
* Remove references to the identity token
* Move email changes to identity
* Move account menu into a turbo-frame
* Create tenants from a tenanted route
2025-10-31 16:26:08 +01:00

33 lines
778 B
Ruby

class JoinCodesController < ApplicationController
require_untenanted_access
allow_unauthenticated_access
before_action :set_join_code
def new
@account_name = ApplicationRecord.with_tenant(tenant) { Account.sole.name }
end
def create
Identity.transaction do
identity = Identity.find_or_create_by(email_address: params.expect(:email_address))
identity.memberships.create!(tenant: tenant, join_code: code)
identity.send_magic_link
end
redirect_to session_magic_link_path
end
private
def set_join_code
@join_code ||= ApplicationRecord.with_tenant(tenant) { Account::JoinCode.active.find_by(code: code) }
end
def tenant
params.expect(:tenant)
end
def code
params.expect(:code)
end
end