Prohibit duplicate memberships

This commit is contained in:
Stanko K.R.
2025-11-05 11:57:40 +01:00
parent 0f0d800d01
commit cfdd7ab1cb
11 changed files with 150 additions and 7 deletions
+4 -2
View File
@@ -10,8 +10,10 @@ class JoinCodesController < ApplicationController
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 = Identity.find_or_create_by!(email_address: params.expect(:email_address))
identity.memberships.find_or_create_by!(tenant: tenant) do |membership|
membership.join_code = code
end
identity.send_magic_link
end