diff options
author | Logan Hunt <loganhunt@simponic.xyz> | 2022-04-06 14:41:19 -0600 |
---|---|---|
committer | Logan Hunt <loganhunt@simponic.xyz> | 2022-04-06 14:41:19 -0600 |
commit | 61c2c9370a0e0139bdb9cab1de64723d60b2682c (patch) | |
tree | 5271f40facc03f4d727b268c1e3ab69f865b17dd /lib/aggiedit_web/live/post_live/index.ex | |
parent | 5ad6bbfce753e048a4f866ad6324f4b4d6f16618 (diff) | |
download | aggiedit-61c2c9370a0e0139bdb9cab1de64723d60b2682c.tar.gz aggiedit-61c2c9370a0e0139bdb9cab1de64723d60b2682c.zip |
Fix authentication on posts page
Diffstat (limited to 'lib/aggiedit_web/live/post_live/index.ex')
-rw-r--r-- | lib/aggiedit_web/live/post_live/index.ex | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/aggiedit_web/live/post_live/index.ex b/lib/aggiedit_web/live/post_live/index.ex index 0b12ed0..1bf7bc3 100644 --- a/lib/aggiedit_web/live/post_live/index.ex +++ b/lib/aggiedit_web/live/post_live/index.ex @@ -5,8 +5,12 @@ defmodule AggieditWeb.PostLive.Index do alias Aggiedit.Rooms.Post @impl true - def mount(_params, _session, socket) do - {:ok, assign(socket, :posts, list_posts())} + def mount(_params, session, socket) do + socket = assign_socket_user(session, socket) + case socket.assigns do + %{:current_user => user} -> {:ok, assign(socket, :posts, list_posts())} + _ -> {:ok, socket |> put_flash(:error, "You must log in to access this page.") |> redirect(to: Routes.user_session_path(socket, :new))} + end end @impl true |