From 90c32c2afdc8e21431ff4356326ea1e4e135aa71 Mon Sep 17 00:00:00 2001 From: Moritz Date: Tue, 6 Jan 2026 17:18:33 +0100 Subject: [PATCH] feat: add role relationship to User resource Add belongs_to :role relationship to User resource and register Authorization domain in config. --- config/config.exs | 2 +- lib/accounts/user.ex | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/config/config.exs b/config/config.exs index 5fcfcf5..cc338b2 100644 --- a/config/config.exs +++ b/config/config.exs @@ -49,7 +49,7 @@ config :spark, config :mv, ecto_repos: [Mv.Repo], generators: [timestamp_type: :utc_datetime], - ash_domains: [Mv.Membership, Mv.Accounts, Mv.MembershipFees] + ash_domains: [Mv.Membership, Mv.Accounts, Mv.MembershipFees, Mv.Authorization] # Configures the endpoint config :mv, MvWeb.Endpoint, diff --git a/lib/accounts/user.ex b/lib/accounts/user.ex index dbc62b2..b0d919b 100644 --- a/lib/accounts/user.ex +++ b/lib/accounts/user.ex @@ -357,6 +357,11 @@ defmodule Mv.Accounts.User do # This automatically creates a `member_id` attribute in the User table # The relationship is optional (allow_nil? true by default) belongs_to :member, Mv.Membership.Member + + # 1:1 relationship - User belongs to a Role + # This automatically creates a `role_id` attribute in the User table + # The relationship is optional (allow_nil? true by default) + belongs_to :role, Mv.Authorization.Role end identities do