Add Role.get_admin_role for Release.seed_admin
Used by Mv.Release to resolve Admin role when creating/updating admin user from ENV.
This commit is contained in:
parent
2f821a7cce
commit
556c11e08c
1 changed files with 14 additions and 0 deletions
|
|
@ -181,4 +181,18 @@ defmodule Mv.Authorization.Role do
|
||||||
|> Ash.Query.filter(name == "Mitglied")
|
|> Ash.Query.filter(name == "Mitglied")
|
||||||
|> Ash.read_one(authorize?: false, domain: Mv.Authorization)
|
|> Ash.read_one(authorize?: false, domain: Mv.Authorization)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Returns the Admin role if it exists.
|
||||||
|
|
||||||
|
Used by release tasks (e.g. seed_admin) and OIDC role sync to assign the admin role.
|
||||||
|
"""
|
||||||
|
@spec get_admin_role() :: {:ok, t() | nil} | {:error, term()}
|
||||||
|
def get_admin_role do
|
||||||
|
require Ash.Query
|
||||||
|
|
||||||
|
__MODULE__
|
||||||
|
|> Ash.Query.filter(name == "Admin")
|
||||||
|
|> Ash.read_one(authorize?: false, domain: Mv.Authorization)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue