Compare commits

...

3 commits

5 changed files with 45 additions and 27 deletions

View file

@ -1,6 +1,6 @@
<main class="container"> <main class="container">
<.flash_group flash={@flash} /> <.flash_group flash={@flash} />
<.navbar is-fixed-top> <.navbar is-fixed-top is-light>
<.navbar_brand> <.navbar_brand>
<.navbar_item> <.navbar_item>
<.title is-4> <.title is-4>
@ -12,7 +12,7 @@
</.navbar_brand> </.navbar_brand>
<.navbar_menu id="navbar_top"> <.navbar_menu id="navbar_top">
<%= if @current_user do %> <%!-- <%= if @current_user do %>
<.navbar_start> <.navbar_start>
<.navbar_item has-dropdown is-hoverable> <.navbar_item has-dropdown is-hoverable>
<.navbar_link> <.navbar_link>
@ -50,7 +50,7 @@
</.navbar_dropdown> </.navbar_dropdown>
</.navbar_item> </.navbar_item>
</.navbar_start> </.navbar_start>
<% end %> <% end %> --%>
<.navbar_end> <.navbar_end>
<%= if @current_user do %> <%= if @current_user do %>
@ -64,16 +64,16 @@
</.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 %>
@ -84,22 +84,16 @@
<.navbar_dropdown> <.navbar_dropdown>
<%= if @current_user do %> <%= if @current_user do %>
<.navbar_item> <.link href={~p"/users/settings"} class="navbar-item">
<.link href={~p"/users/settings"}> Settings
Settings </.link>
</.link> <.link href={~p"/users/log_out"} method="delete" class="navbar-item">
</.navbar_item> Log out
<.navbar_item> </.link>
<.link href={~p"/users/log_out"} method="delete">
Log out
</.link>
</.navbar_item>
<% else %> <% else %>
<.navbar_item> <.link href={~p"/users/log_in"} class="navbar-item">
<.link href={~p"/users/log_in"}> Log in
Log in </.link>
</.link>
</.navbar_item>
<% end %> <% end %>
</.navbar_dropdown> </.navbar_dropdown>
</.navbar_item> </.navbar_item>

View 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

View file

@ -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

View file

@ -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

View file

@ -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