wip-feat: user, login/logout, authentication/authorization

This commit is contained in:
2025-04-28 21:45:12 -05:00
parent 7045116b56
commit 1b1feaebec
22 changed files with 681 additions and 15 deletions

21
templates/bare.html.twig Normal file
View File

@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>{% block title %}Welcome!{% endblock %}</title>
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 128 128%22><text y=%221.2em%22 font-size=%2296%22>⚫️</text><text y=%221.3em%22 x=%220.2em%22 font-size=%2276%22 fill=%22%23fff%22>sf</text></svg>">
{% block stylesheets %}
<link rel="stylesheet" href="{{ asset('styles/app.css') }}">
{% endblock %}
{% block javascripts %}
{% block importmap %}{{ importmap('app') }}{% endblock %}
{% endblock %}
</head>
<body class="bg-cyan-950 flex flex-col">
<h1 class="px-4 py-4 text-3xl font-extrabold text-orange-500">Torsearch</h1>
<div class="flex flex-col justify-center items-center">
{% block body %}{% endblock %}
</div>
</body>
</html>

View File

@@ -6,7 +6,12 @@
<div class="md:flex md:items-center md:gap-12">
<nav aria-label="Global" class="md:block">
<ul class="flex items-center gap-6 text-sm">
<twig:ux:icon name="fluent:alert-12-regular" width="30px" class="text-gray-950 bg-orange-500 rounded-full p-2"/>
<li><twig:ux:icon name="fluent:alert-12-regular" width="30px" class="text-gray-950 bg-orange-500 rounded-full p-2"/></li>
<li>
<a href="{{ path('app_logout') }}">
<twig:ux:icon name="material-symbols:logout" width="25px" class="text-orange-500" />
</a>
</li>
</ul>
</nav>
</div>

View File

@@ -68,19 +68,17 @@
</ul>
</div>
<div class="sticky inset-x-0 bottom-0 border-t border-gray-100">
<a href="#" class="flex items-center gap-2 bg-white p-4 hover:bg-gray-50">
<img
alt=""
src="https://images.unsplash.com/photo-1600486913747-55e5470d6f40?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1770&q=80"
class="size-10 rounded-full object-cover"
/>
<div class="sticky inset-x-0 bottom-0 border-t border-orange-500">
<a href="#" class="flex items-center gap-2 p-4 bg-orange-500 hover:bg-opacity-80 bg-clip-padding backdrop-filter backdrop-blur-md bg-opacity-60">
<span class="rounded-full p-2 border-orange-500 border-2">
<twig:ux:icon name="ri:user-line" width="30" class="text-gray-50"/>
</span>
<div>
<p class="text-xs">
<strong class="block font-medium">Eric Frusciante</strong>
<strong class="block font-medium text-white">Eric Frusciante</strong>
<span> eric@frusciante.com </span>
<span class="text-white"> eric@frusciante.com </span>
</p>
</div>
</a>

View File

@@ -0,0 +1,52 @@
{% extends 'bare.html.twig' %}
{% block title %}Log in &mdash; Torsearch{% endblock %}
{% block body %}
<div class="flex flex-col bg-orange-500 p-4 rounded-lg gap-2 min-w-96">
<h2 class="text-xl text-gray-50">Login</h2>
<form method="post" class="flex flex-col gap-2">
{% if error %}
<div class="bg-red-400 border-red-600 rounded p-2 text-red-600">{{ error.messageKey|trans(error.messageData, 'security') }}</div>
{% endif %}
{% if app.user %}
<div class="mb-3">
You are logged in as {{ app.user.userIdentifier }}, <a href="{{ path('app_logout') }}">Logout</a>
</div>
{% endif %}
<label for="username" class="mb-2 flex flex-col text-gray-950">
Email
<input type="email"
value="{{ last_username }}"
name="_username"
id="username"
class="bg-gray-50 text-gray-950 p-1 rounded-md"
autocomplete="email"
required autofocus>
</label>
<label for="password" class="mb-2 flex flex-col text-gray-950">
Password
<input type="password"
name="_password"
id="password"
class="bg-gray-50 text-gray-950 p-1 rounded-md"
autocomplete="current-password"
required>
</label>
<input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}" data-controller="csrf-protection">
<div class="mb-2">
<input type="checkbox" name="_remember_me" id="_remember_me">
<label for="_remember_me">Remember me</label>
</div>
<button class="bg-green-600 px-1.5 py-1 rounded-md text-gray-50" type="submit">
Sign in
</button>
</form>
</div>
{% endblock %}

View File

@@ -0,0 +1,43 @@
{% extends 'bare.html.twig' %}
{% block title %}Register{% endblock %}
{% block body %}
<div class="flex flex-col bg-orange-500 p-4 rounded-lg gap-2 min-w-96">
<h2 class="text-xl text-gray-50">Register</h2>
{{ form_errors(registrationForm) }}
{{ form_start(registrationForm) }}
<label for="name" class="flex flex-col mb-2">
{{ field_label(registrationForm.name) }}
<input type="text"
name="{{ field_name(registrationForm.name) }}"
id="{{ field_name(registrationForm.name) }}"
value="{{ field_value(registrationForm.name) }}"
class="bg-gray-50 text-gray-950 p-1 rounded-md" />
</label>
<label for="email" class="flex flex-col mb-2">
{{ field_label(registrationForm.email) }}
<input type="email"
name="{{ field_name(registrationForm.email) }}"
id="{{ field_name(registrationForm.email) }}"
value="{{ field_value(registrationForm.email) }}"
class="bg-gray-50 text-gray-950 p-1 rounded-md" />
</label>
<label for="password" class="flex flex-col mb-2">
{{ field_label(registrationForm.plainPassword) }}
<input type="password"
name="{{ field_name(registrationForm.plainPassword) }}"
id="{{ field_name(registrationForm.plainPassword) }}"
value="{{ field_value(registrationForm.plainPassword) }}"
class="bg-gray-50 text-gray-950 p-1 rounded-md" />
</label>
<button type="submit" class="bg-green-600 px-1.5 py-1 rounded-md text-gray-50">Register</button>
{{ form_end(registrationForm) }}
</div>
{% endblock %}