diff --git a/app/Console/Commands/CreateUser.php b/app/Console/Commands/CreateUser.php
new file mode 100644
index 0000000..7f12e60
--- /dev/null
+++ b/app/Console/Commands/CreateUser.php
@@ -0,0 +1,33 @@
+confirm('Should this user be a superuser?');
+ $username = $this->ask('What is the username?');
+ $email = $this->ask('What is the email?');
+ $password = $this->secret('What is the password?');
+
+ $user = User::create([
+ 'name' => $username,
+ 'email' => $email,
+ 'password' => Hash::make($password),
+ 'is_superuser' => $isSuperuser,
+ ]);
+
+ $this->table(['ID', 'Username', 'Email', 'Superuser'], [
+ [$user->id, $user->name, $user->email, $user->is_superuser ? 'Yes' : 'No'],
+ ]);
+ }
+}
diff --git a/app/Http/Controllers/UsersController.php b/app/Http/Controllers/UsersController.php
index 8933385..0e71339 100644
--- a/app/Http/Controllers/UsersController.php
+++ b/app/Http/Controllers/UsersController.php
@@ -6,6 +6,7 @@
use Inertia\Response;
use Influx\Models\User;
use Illuminate\Http\Request;
+use Illuminate\Http\RedirectResponse;
use Illuminate\Contracts\Hashing\Hasher;
class UsersController extends Controller
@@ -91,4 +92,20 @@ public function update(Request $request, int $id): Response
return Inertia::render('Users/Edit', ['user' => $user]);
}
+
+ /**
+ * Delete a user account.
+ */
+ public function delete(int $id): RedirectResponse
+ {
+ $user = User::findOrFail($id);
+
+ try {
+ $user->delete();
+ } catch (\Exception $ex) {
+ throw new \Exception($ex->getMessage());
+ };
+
+ return redirect()->intended(route('users.index', absolute: false));;
+ }
}
diff --git a/package-lock.json b/package-lock.json
index cd9a9cc..26f3c45 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,5 +1,5 @@
{
- "name": "influxdev",
+ "name": "influx",
"lockfileVersion": 3,
"requires": true,
"packages": {
diff --git a/resources/js/Pages/Users/DeleteUserForm.tsx b/resources/js/Pages/Users/DeleteUserForm.tsx
new file mode 100644
index 0000000..6dee68b
--- /dev/null
+++ b/resources/js/Pages/Users/DeleteUserForm.tsx
@@ -0,0 +1,48 @@
+import { useState } from 'react';
+import Modal from '@/Components/Modal';
+import { router } from '@inertiajs/react';
+import DangerButton from '@/Components/DangerButton';
+import SecondaryButton from '@/Components/SecondaryButton';
+
+export default function DeleteUserForm({ id }: { id: number }) {
+ const [open, setOpen] = useState(false);
+ const [submitting, setSubmitting] = useState(false);
+
+ const deleteUser = () => {
+ setSubmitting(true);
+
+ router.delete(`/users/${id}`, {
+ onError: (error) => console.error(error)
+ });
+ };
+
+ return (
+ <>
+
+ Deleting this user account will revoke their access immediately.
+
+ Are you sure?
+
+
+