Hide system actor from user list and block show/edit
Index: filter out SystemActor.system_user_email() in query. Show/Form: redirect to /users with flash when viewing or editing system actor user. Index format_error: handle Ash errors without :message field.
This commit is contained in:
parent
b7f37c80bd
commit
8ad5201e1a
3 changed files with 47 additions and 9 deletions
|
|
@ -75,9 +75,16 @@ defmodule MvWeb.UserLive.Show do
|
|||
actor = current_actor(socket)
|
||||
user = Ash.get!(Mv.Accounts.User, id, domain: Mv.Accounts, load: [:member], actor: actor)
|
||||
|
||||
{:ok,
|
||||
socket
|
||||
|> assign(:page_title, gettext("Show User"))
|
||||
|> assign(:user, user)}
|
||||
if to_string(user.email) == Mv.Helpers.SystemActor.system_user_email() do
|
||||
{:ok,
|
||||
socket
|
||||
|> put_flash(:error, gettext("This user cannot be viewed."))
|
||||
|> push_navigate(to: ~p"/users")}
|
||||
else
|
||||
{:ok,
|
||||
socket
|
||||
|> assign(:page_title, gettext("Show User"))
|
||||
|> assign(:user, user)}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue