first commit

This commit is contained in:
julien
2026-03-16 01:47:07 +01:00
commit 8f7e61bda0
185 changed files with 27731 additions and 0 deletions

View File

@@ -0,0 +1,74 @@
{% extends "layout.twig" %}
{% block title %}Tableau de bord Créer un utilisateur{% endblock %}
{% block content %}
<h2>Créer un utilisateur</h2>
{% include 'partials/_admin_nav.twig' %}
<div class="form-container form-container--narrow">
<div class="form-container__panel">
{% if error %}
<div class="alert alert--danger">{{ error }}</div>
{% endif %}
<form method="post" action="/admin/users/create" class="form-container__form">
<input type="hidden" name="{{ csrf.keys.name }}" value="{{ csrf.name }}">
<input type="hidden" name="{{ csrf.keys.value }}" value="{{ csrf.value }}">
<p class="form-container__field">
<label for="username" class="form-container__label">
<span>Nom d'utilisateur</span>
<input type="text" id="username" name="username" required minlength="3" maxlength="50" autofocus
class="form-container__input">
</label>
<small class="form-container__hint">Minimum 3 caractères</small>
</p>
<p class="form-container__field">
<label for="email" class="form-container__label">
<span>Email</span>
<input type="email" id="email" name="email" required class="form-container__input">
</label>
</p>
<p class="form-container__field">
<label for="password" class="form-container__label">
<span>Mot de passe</span>
<input type="password" id="password" name="password" required minlength="8"
class="form-container__input">
</label>
<small class="form-container__hint">Minimum 8 caractères</small>
</p>
<p class="form-container__field">
<label for="password_confirm" class="form-container__label">
<span>Confirmer le mot de passe</span>
<input type="password" id="password_confirm" name="password_confirm" required minlength="8"
class="form-container__input">
</label>
</p>
<p class="form-container__field">
<label for="role" class="form-container__label">
<span>Rôle</span>
<select id="role" name="role" class="form-container__select">
<option value="user">Utilisateur</option>
<option value="editor">Éditeur</option>
</select>
</label>
</p>
<div class="form-container__actions">
<div class="form-container__action">
<button type="submit" class="btn btn--primary btn--lg btn--full">Créer l'utilisateur</button>
</div>
<div class="form-container__action">
<a href="/admin/users" class="btn btn--secondary btn--lg btn--full">Annuler</a>
</div>
</div>
</form>
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,95 @@
{% extends "layout.twig" %}
{% block title %}Tableau de bord Utilisateurs{% endblock %}
{% block content %}
<h2>Gestion des utilisateurs</h2>
{% include 'partials/_admin_nav.twig' %}
<p>
<a href="/admin/users/create" class="btn btn--primary">+ Ajouter un utilisateur</a>
</p>
{% if error %}
<div class="alert alert--danger">{{ error }}</div>
{% endif %}
{% if success %}
<div class="alert alert--success">{{ success }}</div>
{% endif %}
{% if users is not empty %}
<table class="admin-table">
<thead>
<tr>
<th>Nom d'utilisateur</th>
<th>Email</th>
<th>Rôle</th>
<th>Inscrit le</th>
<th>Modifier le rôle</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for user in users %}
<tr>
<td data-label="Nom d'utilisateur">
<strong>{{ user.username }}</strong>
{% if user.id == currentUserId %}
<em class="admin-table__self">(vous)</em>
{% endif %}
</td>
<td data-label="Email">{{ user.email }}</td>
<td data-label="Rôle">
{% if user.isAdmin() %}
<span class="badge badge--admin">Admin</span>
{% elseif user.isEditor() %}
<span class="badge badge--editor">Éditeur</span>
{% else %}
<span class="badge badge--user">Utilisateur</span>
{% endif %}
</td>
<td data-label="Inscrit le">{{ user.createdAt|date("d/m/Y") }}</td>
<td data-label="Modifier le rôle">
{% if not user.isAdmin() and user.id != currentUserId %}
<form method="post" action="/admin/users/role/{{ user.id }}" class="u-inline-form">
<input type="hidden" name="{{ csrf.keys.name }}" value="{{ csrf.name }}">
<input type="hidden" name="{{ csrf.keys.value }}" value="{{ csrf.value }}">
<div class="u-inline-actions">
<select name="role" class="admin-table__role-select">
<option value="user" {% if user.role == 'user' %}selected{% endif %}>Utilisateur</option>
<option value="editor" {% if user.role == 'editor' %}selected{% endif %}>Éditeur</option>
<option value="admin" {% if user.role == 'admin' %}selected{% endif %}>Admin</option>
</select>
<button type="submit" class="btn btn--sm btn--secondary">Modifier</button>
</div>
</form>
{% else %}
<span class="admin-table__muted">—</span>
{% endif %}
</td>
<td data-label="Actions">
{% if not user.isAdmin() and user.id != currentUserId %}
<div class="u-inline-actions">
<form method="post" action="/admin/users/delete/{{ user.id }}" class="u-inline-form">
<input type="hidden" name="{{ csrf.keys.name }}" value="{{ csrf.name }}">
<input type="hidden" name="{{ csrf.keys.value }}" value="{{ csrf.value }}">
<button type="submit" class="btn btn--sm btn--danger"
onclick="return confirm('Supprimer l\'utilisateur « {{ user.username }} » ?')">
Supprimer
</button>
</form>
</div>
{% else %}
<span class="admin-table__muted">—</span>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p><em>Aucun utilisateur.</em></p>
{% endif %}
{% endblock %}