diff --git a/lib/towerops/accounts/user_consent.ex b/lib/towerops/accounts/user_consent.ex index 27595478..afb0f168 100644 --- a/lib/towerops/accounts/user_consent.ex +++ b/lib/towerops/accounts/user_consent.ex @@ -48,9 +48,6 @@ defmodule Towerops.Accounts.UserConsent do |> validate_required([:user_id, :consent_type, :version, :granted_at]) |> validate_inclusion(:consent_type, @consent_types) |> foreign_key_constraint(:user_id) - |> unique_constraint([:user_id, :consent_type, :version], - name: :user_consents_user_id_consent_type_version_index - ) end @doc """ @@ -64,7 +61,8 @@ defmodule Towerops.Accounts.UserConsent do end defp validate_not_already_revoked(changeset) do - if get_field(changeset, :revoked_at) do + # Check the original struct's revoked_at, not the changeset's pending changes + if changeset.data.revoked_at do add_error(changeset, :revoked_at, "consent already revoked") else changeset diff --git a/lib/towerops_web/live/user_registration_live.ex b/lib/towerops_web/live/user_registration_live.ex index 20fa686e..1bf41e94 100644 --- a/lib/towerops_web/live/user_registration_live.ex +++ b/lib/towerops_web/live/user_registration_live.ex @@ -243,12 +243,16 @@ defmodule ToweropsWeb.UserRegistrationLive do />
-
-