Init an admin user in prod closes #381 #409
1 changed files with 14 additions and 0 deletions
|
|
@ -181,4 +181,18 @@ defmodule Mv.Authorization.Role do
|
|||
|> Ash.Query.filter(name == "Mitglied")
|
||||
|> Ash.read_one(authorize?: false, domain: Mv.Authorization)
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue