defmodule PhoenixKitWeb.TestRequireAuthLive do @moduledoc """ Test component for phoenix_kit_mount_current_scope authentication level. This page shows current scope information without requiring authentication. """ use PhoenixKitWeb, :live_view alias PhoenixKit.Users.Auth.Scope def render(assigns) do ~H"""

phoenix_kit_mount_current_scope

This page uses PhoenixKit phoenix_kit_mount_current_scope. Modern scope system that mounts current scope without requiring authentication.

{if Scope.authenticated?(@phoenix_kit_current_scope), do: "User is logged in!", else: "No user logged in"}

Scope Status: authenticated? = {Scope.authenticated?(@phoenix_kit_current_scope)}

User Status: anonymous? = {Scope.anonymous?(@phoenix_kit_current_scope)}

<%= if Scope.authenticated?(@phoenix_kit_current_scope) do %>

Email: {Scope.user_email(@phoenix_kit_current_scope)}

ID: {Scope.user_id(@phoenix_kit_current_scope)}

<%= if Scope.user(@phoenix_kit_current_scope).confirmed_at do %>

Status: Confirmed at {Scope.user(@phoenix_kit_current_scope).confirmed_at}

<% else %>

Status: Not confirmed

<% end %> <% else %>

Page is accessible but scope is anonymous

Both @phoenix_kit_current_scope and @phoenix_kit_current_user available

<% end %>
PhoenixKit Scope Mount: ALWAYS ACCESSIBLE
""" end def mount(_params, _session, socket) do {:ok, socket} end end