Add home live beind login
This commit is contained in:
parent
caaa5d0387
commit
3a1060826f
5 changed files with 35 additions and 11 deletions
|
@ -58,24 +58,24 @@
|
|||
<%= @current_user.email %>
|
||||
</.navbar_item>
|
||||
|
||||
<%!-- <.navbar_item has-dropdown is-hoverable>
|
||||
<.navbar_item has-dropdown is-hoverable>
|
||||
<.navbar_link>
|
||||
System
|
||||
</.navbar_link>
|
||||
|
||||
<.navbar_dropdown>
|
||||
<.navbar_item>
|
||||
<%!-- <.navbar_item>
|
||||
<.link>Software Updates</.link>
|
||||
</.navbar_item>
|
||||
<.navbar_divider />
|
||||
<.navbar_item>
|
||||
<.link>Packages</.link>
|
||||
</.navbar_item>
|
||||
<.navbar_item>
|
||||
<.link>Services</.link>
|
||||
</.navbar_item>
|
||||
</.navbar_dropdown>
|
||||
</.navbar_item> --%>
|
||||
<.link href={~p"/services"} class="navbar-item">
|
||||
Services
|
||||
</.link>
|
||||
</.navbar_dropdown>
|
||||
</.navbar_item>
|
||||
<% end %>
|
||||
<.navbar_item has-dropdown is-hoverable>
|
||||
<.navbar_link>
|
||||
|
|
15
lib/freedive_web/live/home_live.ex
Normal file
15
lib/freedive_web/live/home_live.ex
Normal file
|
@ -0,0 +1,15 @@
|
|||
defmodule FreediveWeb.HomeLive do
|
||||
use FreediveWeb, :live_view
|
||||
|
||||
def render(assigns) do
|
||||
~H"""
|
||||
<.section>
|
||||
<.title>Home</.title>
|
||||
</.section>
|
||||
"""
|
||||
end
|
||||
|
||||
def mount(_params, _session, socket) do
|
||||
{:ok, socket}
|
||||
end
|
||||
end
|
|
@ -20,7 +20,7 @@ defmodule FreediveWeb.Router do
|
|||
scope "/", FreediveWeb do
|
||||
pipe_through :browser
|
||||
|
||||
get "/", PageController, :home
|
||||
# get "/", PageController, :home
|
||||
end
|
||||
|
||||
# Other scopes may use custom stacks.
|
||||
|
@ -68,6 +68,7 @@ defmodule FreediveWeb.Router do
|
|||
|
||||
live_session :require_authenticated_user,
|
||||
on_mount: [{FreediveWeb.UserAuth, :ensure_authenticated}] do
|
||||
live "/", HomeLive
|
||||
live "/users/settings", UserSettingsLive, :edit
|
||||
live "/users/settings/confirm_email/:token", UserSettingsLive, :confirm_email
|
||||
end
|
||||
|
|
|
@ -3,6 +3,6 @@ defmodule FreediveWeb.PageControllerTest do
|
|||
|
||||
test "GET /", %{conn: conn} do
|
||||
conn = get(conn, ~p"/")
|
||||
assert html_response(conn, 200) =~ "Under Construction"
|
||||
assert html_response(conn, 302) =~ "redirected"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -51,8 +51,12 @@ defmodule FreediveWeb.UserConfirmationLiveTest do
|
|||
|
||||
assert {:ok, conn} = result
|
||||
|
||||
# Home is now behind login page and only latest flash message is shown
|
||||
assert Phoenix.Flash.get(conn.assigns.flash, :error) =~
|
||||
"User confirmation link is invalid or it has expired"
|
||||
"You must log in to access this page."
|
||||
|
||||
# assert Phoenix.Flash.get(conn.assigns.flash, :error) =~
|
||||
# "User confirmation link is invalid or it has expired"
|
||||
|
||||
# when logged in
|
||||
conn =
|
||||
|
@ -80,8 +84,12 @@ defmodule FreediveWeb.UserConfirmationLiveTest do
|
|||
|> render_submit()
|
||||
|> follow_redirect(conn, ~p"/")
|
||||
|
||||
# Home is now behind login page and only latest flash message is shown
|
||||
assert Phoenix.Flash.get(conn.assigns.flash, :error) =~
|
||||
"User confirmation link is invalid or it has expired"
|
||||
"You must log in to access this page."
|
||||
|
||||
# assert Phoenix.Flash.get(conn.assigns.flash, :error) =~
|
||||
# "User confirmation link is invalid or it has expired"
|
||||
|
||||
refute Accounts.get_user!(user.id).confirmed_at
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue