remove unnecessary auth check on invite page

This commit is contained in:
shibao 2023-03-19 00:26:37 -04:00
parent bf91eadd8e
commit d495db0bb3
10 changed files with 29 additions and 54 deletions

View File

@ -6,21 +6,11 @@ defmodule MemexWeb.InviteLive.Index do
use MemexWeb, :live_view use MemexWeb, :live_view
alias Memex.Accounts alias Memex.Accounts
alias Memex.Accounts.{Invite, Invites} alias Memex.Accounts.{Invite, Invites}
alias MemexWeb.HomeLive
alias Phoenix.LiveView.JS alias Phoenix.LiveView.JS
@impl true @impl true
def mount(_params, _session, %{assigns: %{current_user: current_user}} = socket) do def mount(_params, _session, socket) do
socket = {:ok, socket |> display_invites()}
if current_user |> Map.get(:role) == :admin do
socket |> display_invites()
else
prompt = dgettext("errors", "you are not authorized to view this page")
return_to = Routes.live_path(Endpoint, HomeLive)
socket |> put_flash(:error, prompt) |> push_redirect(to: return_to)
end
{:ok, socket}
end end
@impl true @impl true

View File

@ -99,7 +99,7 @@ msgstr ""
msgid "document your processes, attaching contexts to each step" msgid "document your processes, attaching contexts to each step"
msgstr "" msgstr ""
#: lib/memex_web/live/invite_live/index.ex:33 #: lib/memex_web/live/invite_live/index.ex:23
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "edit invite" msgid "edit invite"
msgstr "" msgstr ""
@ -154,7 +154,7 @@ msgid "invite only"
msgstr "" msgstr ""
#: lib/memex_web/components/core_components/topbar.html.heex:58 #: lib/memex_web/components/core_components/topbar.html.heex:58
#: lib/memex_web/live/invite_live/index.ex:41 #: lib/memex_web/live/invite_live/index.ex:31
#: lib/memex_web/live/invite_live/index.html.heex:3 #: lib/memex_web/live/invite_live/index.html.heex:3
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "invites" msgid "invites"
@ -170,7 +170,7 @@ msgstr ""
msgid "multi-user:" msgid "multi-user:"
msgstr "" msgstr ""
#: lib/memex_web/live/invite_live/index.ex:37 #: lib/memex_web/live/invite_live/index.ex:27
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "new invite" msgid "new invite"
msgstr "" msgstr ""

View File

@ -122,11 +122,6 @@ msgstr ""
msgid "sorry, this invite was not found or expired" msgid "sorry, this invite was not found or expired"
msgstr "" msgstr ""
#: lib/memex_web/live/invite_live/index.ex:18
#, elixir-autogen, elixir-format, fuzzy
msgid "you are not authorized to view this page"
msgstr ""
#: lib/memex_web/controllers/user_settings_controller.ex:84 #: lib/memex_web/controllers/user_settings_controller.ex:84
#, elixir-autogen, elixir-format, fuzzy #, elixir-autogen, elixir-format, fuzzy
msgid "email change link is invalid or it has expired." msgid "email change link is invalid or it has expired."

View File

@ -15,27 +15,27 @@ msgstr ""
msgid "%{email} confirmed successfully." msgid "%{email} confirmed successfully."
msgstr "" msgstr ""
#: lib/memex_web/live/invite_live/index.ex:53 #: lib/memex_web/live/invite_live/index.ex:43
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "%{invite_name} deleted succesfully" msgid "%{invite_name} deleted succesfully"
msgstr "" msgstr ""
#: lib/memex_web/live/invite_live/index.ex:114 #: lib/memex_web/live/invite_live/index.ex:104
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "%{invite_name} disabled succesfully" msgid "%{invite_name} disabled succesfully"
msgstr "" msgstr ""
#: lib/memex_web/live/invite_live/index.ex:90 #: lib/memex_web/live/invite_live/index.ex:80
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "%{invite_name} enabled succesfully" msgid "%{invite_name} enabled succesfully"
msgstr "" msgstr ""
#: lib/memex_web/live/invite_live/index.ex:68 #: lib/memex_web/live/invite_live/index.ex:58
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "%{invite_name} updated succesfully" msgid "%{invite_name} updated succesfully"
msgstr "" msgstr ""
#: lib/memex_web/live/invite_live/index.ex:136 #: lib/memex_web/live/invite_live/index.ex:126
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "%{user_email} deleted succesfully" msgid "%{user_email} deleted succesfully"
msgstr "" msgstr ""
@ -116,7 +116,7 @@ msgstr ""
msgid "%{name} updated successfully" msgid "%{name} updated successfully"
msgstr "" msgstr ""
#: lib/memex_web/live/invite_live/index.ex:126 #: lib/memex_web/live/invite_live/index.ex:116
#, elixir-autogen, elixir-format, fuzzy #, elixir-autogen, elixir-format, fuzzy
msgid "copied to clipboard" msgid "copied to clipboard"
msgstr "" msgstr ""

View File

@ -97,7 +97,7 @@ msgstr ""
msgid "document your processes, attaching contexts to each step" msgid "document your processes, attaching contexts to each step"
msgstr "" msgstr ""
#: lib/memex_web/live/invite_live/index.ex:33 #: lib/memex_web/live/invite_live/index.ex:23
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "edit invite" msgid "edit invite"
msgstr "" msgstr ""
@ -152,7 +152,7 @@ msgid "invite only"
msgstr "" msgstr ""
#: lib/memex_web/components/core_components/topbar.html.heex:58 #: lib/memex_web/components/core_components/topbar.html.heex:58
#: lib/memex_web/live/invite_live/index.ex:41 #: lib/memex_web/live/invite_live/index.ex:31
#: lib/memex_web/live/invite_live/index.html.heex:3 #: lib/memex_web/live/invite_live/index.html.heex:3
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "invites" msgid "invites"
@ -168,7 +168,7 @@ msgstr ""
msgid "multi-user:" msgid "multi-user:"
msgstr "" msgstr ""
#: lib/memex_web/live/invite_live/index.ex:37 #: lib/memex_web/live/invite_live/index.ex:27
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "new invite" msgid "new invite"
msgstr "" msgstr ""

View File

@ -98,7 +98,7 @@ msgstr ""
msgid "document your processes, attaching contexts to each step" msgid "document your processes, attaching contexts to each step"
msgstr "" msgstr ""
#: lib/memex_web/live/invite_live/index.ex:33 #: lib/memex_web/live/invite_live/index.ex:23
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "edit invite" msgid "edit invite"
msgstr "" msgstr ""
@ -153,7 +153,7 @@ msgid "invite only"
msgstr "" msgstr ""
#: lib/memex_web/components/core_components/topbar.html.heex:58 #: lib/memex_web/components/core_components/topbar.html.heex:58
#: lib/memex_web/live/invite_live/index.ex:41 #: lib/memex_web/live/invite_live/index.ex:31
#: lib/memex_web/live/invite_live/index.html.heex:3 #: lib/memex_web/live/invite_live/index.html.heex:3
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "invites" msgid "invites"
@ -169,7 +169,7 @@ msgstr ""
msgid "multi-user:" msgid "multi-user:"
msgstr "" msgstr ""
#: lib/memex_web/live/invite_live/index.ex:37 #: lib/memex_web/live/invite_live/index.ex:27
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "new invite" msgid "new invite"
msgstr "" msgstr ""

View File

@ -123,11 +123,6 @@ msgstr ""
msgid "sorry, this invite was not found or expired" msgid "sorry, this invite was not found or expired"
msgstr "" msgstr ""
#: lib/memex_web/live/invite_live/index.ex:18
#, elixir-autogen, elixir-format
msgid "you are not authorized to view this page"
msgstr ""
#: lib/memex_web/controllers/user_settings_controller.ex:84 #: lib/memex_web/controllers/user_settings_controller.ex:84
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "email change link is invalid or it has expired." msgid "email change link is invalid or it has expired."

View File

@ -16,27 +16,27 @@ msgstr ""
msgid "%{email} confirmed successfully." msgid "%{email} confirmed successfully."
msgstr "" msgstr ""
#: lib/memex_web/live/invite_live/index.ex:53 #: lib/memex_web/live/invite_live/index.ex:43
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "%{invite_name} deleted succesfully" msgid "%{invite_name} deleted succesfully"
msgstr "" msgstr ""
#: lib/memex_web/live/invite_live/index.ex:114 #: lib/memex_web/live/invite_live/index.ex:104
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "%{invite_name} disabled succesfully" msgid "%{invite_name} disabled succesfully"
msgstr "" msgstr ""
#: lib/memex_web/live/invite_live/index.ex:90 #: lib/memex_web/live/invite_live/index.ex:80
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "%{invite_name} enabled succesfully" msgid "%{invite_name} enabled succesfully"
msgstr "" msgstr ""
#: lib/memex_web/live/invite_live/index.ex:68 #: lib/memex_web/live/invite_live/index.ex:58
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "%{invite_name} updated succesfully" msgid "%{invite_name} updated succesfully"
msgstr "" msgstr ""
#: lib/memex_web/live/invite_live/index.ex:136 #: lib/memex_web/live/invite_live/index.ex:126
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "%{user_email} deleted succesfully" msgid "%{user_email} deleted succesfully"
msgstr "" msgstr ""
@ -117,7 +117,7 @@ msgstr ""
msgid "%{name} updated successfully" msgid "%{name} updated successfully"
msgstr "" msgstr ""
#: lib/memex_web/live/invite_live/index.ex:126 #: lib/memex_web/live/invite_live/index.ex:116
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "copied to clipboard" msgid "copied to clipboard"
msgstr "" msgstr ""

View File

@ -122,11 +122,6 @@ msgstr ""
msgid "sorry, this invite was not found or expired" msgid "sorry, this invite was not found or expired"
msgstr "" msgstr ""
#: lib/memex_web/live/invite_live/index.ex:18
#, elixir-autogen, elixir-format
msgid "you are not authorized to view this page"
msgstr ""
#: lib/memex_web/controllers/user_settings_controller.ex:84 #: lib/memex_web/controllers/user_settings_controller.ex:84
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "email change link is invalid or it has expired." msgid "email change link is invalid or it has expired."

View File

@ -15,27 +15,27 @@ msgstr ""
msgid "%{email} confirmed successfully." msgid "%{email} confirmed successfully."
msgstr "" msgstr ""
#: lib/memex_web/live/invite_live/index.ex:53 #: lib/memex_web/live/invite_live/index.ex:43
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "%{invite_name} deleted succesfully" msgid "%{invite_name} deleted succesfully"
msgstr "" msgstr ""
#: lib/memex_web/live/invite_live/index.ex:114 #: lib/memex_web/live/invite_live/index.ex:104
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "%{invite_name} disabled succesfully" msgid "%{invite_name} disabled succesfully"
msgstr "" msgstr ""
#: lib/memex_web/live/invite_live/index.ex:90 #: lib/memex_web/live/invite_live/index.ex:80
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "%{invite_name} enabled succesfully" msgid "%{invite_name} enabled succesfully"
msgstr "" msgstr ""
#: lib/memex_web/live/invite_live/index.ex:68 #: lib/memex_web/live/invite_live/index.ex:58
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "%{invite_name} updated succesfully" msgid "%{invite_name} updated succesfully"
msgstr "" msgstr ""
#: lib/memex_web/live/invite_live/index.ex:136 #: lib/memex_web/live/invite_live/index.ex:126
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "%{user_email} deleted succesfully" msgid "%{user_email} deleted succesfully"
msgstr "" msgstr ""
@ -116,7 +116,7 @@ msgstr ""
msgid "%{name} updated successfully" msgid "%{name} updated successfully"
msgstr "" msgstr ""
#: lib/memex_web/live/invite_live/index.ex:126 #: lib/memex_web/live/invite_live/index.ex:116
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "copied to clipboard" msgid "copied to clipboard"
msgstr "" msgstr ""