forked from hiway/freedive
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 %>
|
<%= @current_user.email %>
|
||||||
</.navbar_item>
|
</.navbar_item>
|
||||||
|
|
||||||
<%!-- <.navbar_item has-dropdown is-hoverable>
|
<.navbar_item has-dropdown is-hoverable>
|
||||||
<.navbar_link>
|
<.navbar_link>
|
||||||
System
|
System
|
||||||
</.navbar_link>
|
</.navbar_link>
|
||||||
|
|
||||||
<.navbar_dropdown>
|
<.navbar_dropdown>
|
||||||
<.navbar_item>
|
<%!-- <.navbar_item>
|
||||||
<.link>Software Updates</.link>
|
<.link>Software Updates</.link>
|
||||||
</.navbar_item>
|
</.navbar_item>
|
||||||
<.navbar_divider />
|
<.navbar_divider />
|
||||||
<.navbar_item>
|
<.navbar_item>
|
||||||
<.link>Packages</.link>
|
<.link>Packages</.link>
|
||||||
</.navbar_item>
|
</.navbar_item> --%>
|
||||||
<.navbar_item>
|
<.link href={~p"/services"} class="navbar-item">
|
||||||
<.link>Services</.link>
|
Services
|
||||||
</.navbar_item>
|
</.link>
|
||||||
</.navbar_dropdown>
|
</.navbar_dropdown>
|
||||||
</.navbar_item> --%>
|
</.navbar_item>
|
||||||
<% end %>
|
<% end %>
|
||||||
<.navbar_item has-dropdown is-hoverable>
|
<.navbar_item has-dropdown is-hoverable>
|
||||||
<.navbar_link>
|
<.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
|
scope "/", FreediveWeb do
|
||||||
pipe_through :browser
|
pipe_through :browser
|
||||||
|
|
||||||
get "/", PageController, :home
|
# get "/", PageController, :home
|
||||||
end
|
end
|
||||||
|
|
||||||
# Other scopes may use custom stacks.
|
# Other scopes may use custom stacks.
|
||||||
|
@ -68,6 +68,7 @@ defmodule FreediveWeb.Router do
|
||||||
|
|
||||||
live_session :require_authenticated_user,
|
live_session :require_authenticated_user,
|
||||||
on_mount: [{FreediveWeb.UserAuth, :ensure_authenticated}] do
|
on_mount: [{FreediveWeb.UserAuth, :ensure_authenticated}] do
|
||||||
|
live "/", HomeLive
|
||||||
live "/users/settings", UserSettingsLive, :edit
|
live "/users/settings", UserSettingsLive, :edit
|
||||||
live "/users/settings/confirm_email/:token", UserSettingsLive, :confirm_email
|
live "/users/settings/confirm_email/:token", UserSettingsLive, :confirm_email
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,6 +3,6 @@ defmodule FreediveWeb.PageControllerTest do
|
||||||
|
|
||||||
test "GET /", %{conn: conn} do
|
test "GET /", %{conn: conn} do
|
||||||
conn = get(conn, ~p"/")
|
conn = get(conn, ~p"/")
|
||||||
assert html_response(conn, 200) =~ "Under Construction"
|
assert html_response(conn, 302) =~ "redirected"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -51,8 +51,12 @@ defmodule FreediveWeb.UserConfirmationLiveTest do
|
||||||
|
|
||||||
assert {:ok, conn} = result
|
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) =~
|
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
|
# when logged in
|
||||||
conn =
|
conn =
|
||||||
|
@ -80,8 +84,12 @@ defmodule FreediveWeb.UserConfirmationLiveTest do
|
||||||
|> render_submit()
|
|> render_submit()
|
||||||
|> follow_redirect(conn, ~p"/")
|
|> 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) =~
|
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
|
refute Accounts.get_user!(user.id).confirmed_at
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue