This commit is contained in:
parent
a8d9fe6121
commit
9b4f3b140c
19 changed files with 330 additions and 43 deletions
|
|
@ -74,7 +74,7 @@ defmodule MvWeb.LiveHelpers do
|
|||
|
||||
socket =
|
||||
socket
|
||||
|> Phoenix.LiveView.put_flash(:error, "You don't have permission to access this page.")
|
||||
|> maybe_put_access_denied_flash(user)
|
||||
|> Phoenix.LiveView.push_navigate(to: redirect_to)
|
||||
|
||||
{:halt, socket}
|
||||
|
|
@ -82,6 +82,13 @@ defmodule MvWeb.LiveHelpers do
|
|||
end
|
||||
end
|
||||
|
||||
# Only show "no permission" when user is logged in; unauthenticated users are redirected to sign-in without flash.
|
||||
defp maybe_put_access_denied_flash(socket, nil), do: socket
|
||||
|
||||
defp maybe_put_access_denied_flash(socket, _user) do
|
||||
Phoenix.LiveView.put_flash(socket, :error, "You don't have permission to access this page.")
|
||||
end
|
||||
|
||||
defp ensure_user_role_loaded(socket) do
|
||||
user = socket.assigns[:current_user]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue