Skip to content
Snippets Groups Projects
Commit bd82b107 authored by Sofiane Lasri's avatar Sofiane Lasri
Browse files

feat: add user deletion functionality in admin settings

- Added a new route for deleting users with a GET and DELETE method in `routes/web.php`.
- Updated `app.php` configuration to include `protected_account_email`.
- Enhanced the user management view to display a table of users with delete actions in `resources/views/admin/settings/users.blade.php`.
- Implemented the `deleteUser` method in `SettingsController` to handle user deletion.
- Updated `.env.example` and `.env.testing` files to include `PROTECTED_ACCOUNT_EMAIL` configuration.
parent 55f42c83
No related branches found
No related tags found
1 merge request!7Resolve "Ajouter gestion des utilisateurs"
Pipeline #647 passed
......@@ -64,3 +64,5 @@ AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false
VITE_APP_NAME="${APP_NAME}"
PROTECTED_ACCOUNT_EMAIL=null
\ No newline at end of file
......@@ -63,3 +63,4 @@ AWS_USE_PATH_STYLE_ENDPOINT=false
VITE_APP_NAME="${APP_NAME}"
PROTECTED_ACCOUNT_EMAIL="admin@example.com"
\ No newline at end of file
......@@ -3,6 +3,8 @@
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\User;
use Illuminate\Http\RedirectResponse;
use Illuminate\View\View;
class SettingsController extends Controller
......@@ -22,11 +24,21 @@ class SettingsController extends Controller
public function userListPage(): View
{
$users = User::all();
return view('admin.settings.users', [
'headerRoutes' => $this->headerRoutes,
'users' => $users,
]);
}
public function deleteUser(int $id): RedirectResponse
{
User::destroy($id);
return redirect()->route('admin.settings.users');
}
public function generalPage(): View
{
return view('admin.settings.general', [
......
......@@ -124,4 +124,6 @@
],
'supported_image_formats' => ['jpg', 'jpeg', 'png', 'gif', 'webp', 'avif', 'heic', 'heif', 'bmp', 'tiff'],
'protected_account_email' => env('PROTECTED_ACCOUNT_EMAIL', ''),
];
@extends('layouts.admin', ['title' => 'Catégories', 'headerRoutes' => $headerRoutes])
@section('content')
<h5>Information</h5>
<p>Les catégories permettent de regrouper des créations sous un thème commun, qui pourra être associé à une
prestation.</p>
......
@extends('layouts.admin', ['title' => 'Utilisateurs', 'headerRoutes' => $headerRoutes])
@section('content')
<h5>Gérer les accès à votre administration</h5>
<p>Vous pouvez inviter des personnes à accéder à votre panneau d'administration en leur envoyant une invitation par
email.</p>
<p><span class="fw-bold text-danger">Attention !</span> Pour des raisons de simplicité, ces personnes auront les
mêmes droits que vous (sauf la suppression de votre compte).
<strong>Soyez bien certains d'avoir confiance en elles !</strong></p>
<table class="table">
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">Nom</th>
<th scope="col">Adresse e-mail</th>
<th scope="col">S'est déjà connecté ?</th>
<th scope="col">Utilise la double Authentification ?</th>
<th scope="col">Date d'ajout</th>
<th scope="col">Actions</th>
</tr>
</thead>
<tbody>
@foreach($users as $user)
<tr>
<th scope="row">{{ $user->id }}</th>
<td>{{ $user->name }}</td>
<td>{{ $user->email }}</td>
<td>{{ !empty($user->email_verified_at) ? 'Oui' : 'Non' }}</td>
<td>{{ !empty($user->two_factor_confirmed_at) ? 'Oui' : 'Non' }}</td>
<td>{{ $user->created_at->format('d/m/Y H:i') }}</td>
<td>
<x-bs.button href="{{ route('admin.settings.delete-user', $user->id) }}"
size="sm" tag="a" variant="danger">
Supprimer
</x-bs.button>
</td>
</tr>
@endforeach
</tbody>
</table>
@endsection
......@@ -84,6 +84,7 @@
Route::prefix('settings')->name('admin.settings.')->group(function () {
Route::get('/users', [SettingsController::class, 'userListPage'])->name('users');
Route::match(['GET', 'DELETE'], '/users/{id}/delete', [SettingsController::class, 'deleteUser'])->name('delete-user');
Route::get('/general', [SettingsController::class, 'generalPage'])->name('general');
});
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment