diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php
index d306dec..524be45 100644
--- a/app/Http/Controllers/UserController.php
+++ b/app/Http/Controllers/UserController.php
@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
+use Illuminate\Auth\Events\Registered;
use Illuminate\Http\Request;
use App\Models\User;
@@ -22,14 +23,28 @@ class UserController extends Controller
$this->authorize('admin',$o);
$request->validate([
- 'email' => 'required|email|unique:users,email,'.($o ? $o->id : NULL),
+ 'email' => 'required|email|unique:users,email,'.($o->exists ? $o->id : 0),
+ 'name' => 'required|min:3',
+ 'pgp_pubkey' => [
+ 'nullable',
+ 'min:64',
+ //function ($attribute,$value,$fail) { return $fail('Not this time'); }
+ ],
+ 'active' => 'required|boolean',
+ 'admin' => 'required|boolean',
]);
- foreach (['name','email','notes'] as $key)
+ foreach (['name','email','pgp_pubkey','active','admin'] as $key)
$o->{$key} = $request->post($key);
+ if (! $o->exists)
+ $o->password = base64_encode(random_bytes(20));
+
$o->save();
+ if ($o->wasRecentlyCreated)
+ event(new Registered($o));
+
return redirect()->action([self::class,'home']);
}
diff --git a/database/migrations/2021_06_18_133000_update_users.php b/database/migrations/2021_06_18_133000_update_users.php
new file mode 100644
index 0000000..98db015
--- /dev/null
+++ b/database/migrations/2021_06_18_133000_update_users.php
@@ -0,0 +1,42 @@
+text('pgp_pubkey')->nullable();
+ $table->boolean('active')->default(TRUE);
+ $table->dateTime('last_on')->nullable();
+ });
+
+ Schema::table('systems', function (Blueprint $table) {
+ $table->dateTime('last_session')->nullable();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::table('users', function (Blueprint $table) {
+ $table->dropColumn(['pgp_pubkey','active','last_on']);
+ });
+
+ Schema::table('systems', function (Blueprint $table) {
+ $table->dropColumn(['last_session']);
+ });
+ }
+}
diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php
index 52f221c..77351db 100644
--- a/resources/views/auth/login.blade.php
+++ b/resources/views/auth/login.blade.php
@@ -34,15 +34,13 @@
- @error('email')
-
+
+ @error('email')
{{ $message }}
-
- @else
-
+ @else
Your email is required.
-
- @enderror
+ @enderror
+
@@ -53,7 +51,7 @@
-
+
Your password is required.
diff --git a/resources/views/auth/passwords/email.blade.php b/resources/views/auth/passwords/email.blade.php
index b3cbfbd..f0d60ca 100644
--- a/resources/views/auth/passwords/email.blade.php
+++ b/resources/views/auth/passwords/email.blade.php
@@ -29,15 +29,13 @@
- @error('email')
-
+
+ @error('email')
{{ $message }}
-
- @else
-
+ @else
Your email is required.
-
- @enderror
+ @enderror
+
diff --git a/resources/views/auth/passwords/reset.blade.php b/resources/views/auth/passwords/reset.blade.php
index eaffe8c..ab5b7c3 100644
--- a/resources/views/auth/passwords/reset.blade.php
+++ b/resources/views/auth/passwords/reset.blade.php
@@ -30,15 +30,13 @@
- @error('email')
-
+
+ @error('email')
{{ $message }}
-
- @else
-
+ @else
Your email is required.
-
- @enderror
+ @enderror
+
@@ -49,15 +47,13 @@
- @error('password')
-
+
+ @error('password')
{{ $message }}
-
- @else
-
+ @else
Your password is required.
-
- @enderror
+ @enderror
+
@@ -68,9 +64,9 @@
diff --git a/resources/views/auth/register.blade.php b/resources/views/auth/register.blade.php
index d977657..53d09b9 100644
--- a/resources/views/auth/register.blade.php
+++ b/resources/views/auth/register.blade.php
@@ -19,15 +19,13 @@
- @error('name')
-
+
+ @error('name')
{{ $message }}
-
- @else
-
+ @else
Your name is required.
-
- @enderror
+ @enderror
+
@@ -38,15 +36,13 @@
- @error('email')
-
+
+ @error('email')
{{ $message }}
-
- @else
-
+ @else
Your email is required.
-
- @enderror
+ @enderror
+
@@ -57,15 +53,13 @@
@@ -76,9 +70,9 @@
diff --git a/resources/views/domain/addedit.blade.php b/resources/views/domain/addedit.blade.php
index 25f793f..231618f 100644
--- a/resources/views/domain/addedit.blade.php
+++ b/resources/views/domain/addedit.blade.php
@@ -19,15 +19,13 @@
- @error('name')
-
+
+ @error('name')
{{ $message }}
-
- @else
-
+ @else
A name is required.
-
- @enderror
+ @enderror
+
@@ -89,7 +87,7 @@
Home Page
-
+
@@ -68,15 +64,13 @@
- @error('location')
-
+
+ @error('location')
{{ $message }}
-
- @else
-
+ @else
System location is required.
-
- @enderror
+ @enderror
+
@@ -103,16 +97,14 @@
- @error('address')
-
+
+ @error('address')
{{ $message }}
-
- @enderror
- @error('port')
-
+ @enderror
+ @error('port')
{{ $message }}
-
- @enderror
+ @enderror
+
diff --git a/resources/views/user/addedit.blade.php b/resources/views/user/addedit.blade.php
new file mode 100644
index 0000000..5d8738d
--- /dev/null
+++ b/resources/views/user/addedit.blade.php
@@ -0,0 +1,111 @@
+@extends('layouts.app')
+
+@section('htmlheader_title')
+ @if($o->exists) Update @else Add @endif User
+@endsection
+
+@section('content')
+
+@endsection
+
+@section('page-scripts')
+ @if($o->id == Auth::user()->id)
+
+ @endif
+@append
\ No newline at end of file
diff --git a/resources/views/zone/addedit.blade.php b/resources/views/zone/addedit.blade.php
index eab7f80..c54c817 100644
--- a/resources/views/zone/addedit.blade.php
+++ b/resources/views/zone/addedit.blade.php
@@ -19,15 +19,13 @@
- @error('zone_id')
-
+
+ @error('zone_id')
{{ $message }}
-
- @else
-
+ @else
A zone number is required.
-
- @enderror
+ @enderror
+
@@ -41,15 +39,13 @@
@endforeach
- @error('domain_id')
-
+
+ @error('domain_id')
{{ $message }}
-
- @else
-
+ @else
A domain is required.
-
- @enderror
+ @enderror
+
Add a NEW Domain
@@ -64,22 +60,20 @@
@endforeach
- @error('system_id')
-
+
+ @error('system_id')
{{ $message }}
-
- @else
-
+ @else
A system is required.
-
- @enderror
+ @enderror
+
Add a NEW System. This system is the primary mailer/tosser responsible for managing the zone.