feat: assign admin role to admin user in seeds
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
- Create Admin role if it doesn't exist - Assign Admin role to admin@mv.local user - Remove separate create_admin_role script (integrated into seeds)
This commit is contained in:
parent
7b3362dc48
commit
a5081793b0
2 changed files with 51 additions and 6 deletions
|
|
@ -28,9 +28,20 @@ defmodule MvWeb.RoleLive.Index do
|
|||
# Load role if not already loaded (check for Ash.NotLoaded struct)
|
||||
user_with_role =
|
||||
case Map.get(user, :role) do
|
||||
%Ash.NotLoaded{} -> Ash.load!(user, :role, domain: Mv.Accounts)
|
||||
nil -> Ash.load!(user, :role, domain: Mv.Accounts)
|
||||
role when not is_nil(role) -> user
|
||||
%Ash.NotLoaded{} ->
|
||||
case Ash.load(user, :role, domain: Mv.Accounts) do
|
||||
{:ok, loaded_user} -> loaded_user
|
||||
{:error, _} -> user
|
||||
end
|
||||
|
||||
nil ->
|
||||
case Ash.load(user, :role, domain: Mv.Accounts) do
|
||||
{:ok, loaded_user} -> loaded_user
|
||||
{:error, _} -> user
|
||||
end
|
||||
|
||||
role when not is_nil(role) ->
|
||||
user
|
||||
end
|
||||
|
||||
assign(socket, :current_user, user_with_role)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue