diff --git a/app/Console/Commands/MakeAdmin.php b/app/Console/Commands/MakeAdmin.php new file mode 100644 index 0000000..9c45eb4 --- /dev/null +++ b/app/Console/Commands/MakeAdmin.php @@ -0,0 +1,38 @@ +argument('email'))->firstOrfail(); + $o->admin = ! $o->admin; + $o->save(); + + $this->info(sprintf('User [%s] %s an admin',$o->email,$o->admin ? 'IS' : 'is NOT')); + } +} diff --git a/app/Http/Controllers/DomainController.php b/app/Http/Controllers/DomainController.php index 2e33b18..3118b15 100644 --- a/app/Http/Controllers/DomainController.php +++ b/app/Http/Controllers/DomainController.php @@ -20,8 +20,8 @@ class DomainController extends Controller { if ($request->post()) { $request->validate([ - 'name' => 'required|max:8|unique:domains,name,'.$o->id, - 'dnsdomain' => 'nullable|regex:/^(?!:\/\/)(?=.{1,255}$)((.{1,63}\.){1,127}(?![0-9]*$)[a-z0-9-]+\.?)$/i|unique:domains,dnsdomain,'.$o->id, + 'name' => 'required|max:8|unique:domains,name,'.($o->exists ? $o->id : 0), + 'dnsdomain' => 'nullable|regex:/^(?!:\/\/)(?=.{1,255}$)((.{1,63}\.){1,127}(?![0-9]*$)[a-z0-9-]+\.?)$/i|unique:domains,dnsdomain,'.($o->exists ? $o->id : NULL), 'active' => 'required', 'public' => 'required', ]); diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index f9e3454..d9df590 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -2,6 +2,8 @@ namespace App\Http\Controllers; +use Illuminate\Support\Facades\Auth; + use App\Models\Domain; class HomeController extends Controller @@ -12,6 +14,15 @@ class HomeController extends Controller ->with('o',$o); } + /** + * Render a view that summarises the users permissions + */ + public function permissions() + { + return view('auth.permissions') + ->with('user',Auth::user()); + } + /** * System Setup * @@ -19,6 +30,6 @@ class HomeController extends Controller */ public function setup() { - + return view('setup'); } } \ No newline at end of file diff --git a/app/Http/Controllers/SystemController.php b/app/Http/Controllers/SystemController.php new file mode 100644 index 0000000..483411c --- /dev/null +++ b/app/Http/Controllers/SystemController.php @@ -0,0 +1,46 @@ +middleware('auth'); + } + + /** + * Add or edit a node + */ + public function add_edit(Request $request,System $o) + { + if ($request->post()) { + $request->validate([ + 'name' => 'required|min:3|unique:systems,name,'.($o->exists ? $o->id : 0), + 'location' => 'required|min:3', + 'sysop' => 'required|min:3', + 'address' => 'nullable|regex:/^(?!:\/\/)(?=.{1,255}$)((.{1,63}\.){1,127}(?![0-9]*$)[a-z0-9-]+\.?)$/i', + 'port' => 'nullable|digits_between:2,5', + ]); + + foreach (['name','location','sysop','address','port','active','method','notes'] as $key) + $o->{$key} = $request->post($key); + + $o->save(); + + return redirect()->action([self::class,'home']); + } + + return view('system.addedit') + ->with('o',$o); + } + + public function home() + { + return view('system.home'); + } +} diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php new file mode 100644 index 0000000..7aba135 --- /dev/null +++ b/app/Http/Controllers/UserController.php @@ -0,0 +1,42 @@ +middleware('can:admin'); + } + + /** + * Add or edit a node + */ + public function add_edit(Request $request,User $o) + { + if ($request->post()) { + $request->validate([ + 'email' => 'required|email|unique:users,email,'.($o ? $o->id : NULL), + ]); + + foreach (['name','email','notes'] as $key) + $o->{$key} = $request->post($key); + + $o->save(); + + return redirect()->action([self::class,'home']); + } + + return view('user.addedit') + ->with('o',$o); + } + + public function home() + { + return view('user.home'); + } +} diff --git a/app/Models/System.php b/app/Models/System.php new file mode 100644 index 0000000..a41faa1 --- /dev/null +++ b/app/Models/System.php @@ -0,0 +1,19 @@ +id(); + $table->timestamps(); + $table->string('name'); + $table->string('sysop'); + $table->string('location'); + $table->text('notes'); + $table->boolean('active'); + $table->string('address')->nullable(); + $table->integer('port')->nullable(); + $table->integer('method')->nullable(); + }); + + Schema::create('node_system', function (Blueprint $table) { + $table->integer('node_id'); + $table->foreign('node_id')->references('id')->on('nodes'); + $table->integer('system_id'); + $table->foreign('system_id')->references('id')->on('systems'); + }); + + Schema::create('system_user', function (Blueprint $table) { + $table->integer('user_id'); + $table->foreign('user_id')->references('id')->on('users'); + $table->integer('system_id'); + $table->foreign('system_id')->references('id')->on('systems'); + }); + + Schema::table('setups', function (Blueprint $table) { + $table->dropColumn('opt_md'); + $table->integer('zmodem'); + $table->integer('emsi_protocols'); + $table->integer('binkp'); + $table->integer('protocols'); + $table->integer('permissions'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('setups', function (Blueprint $table) { + $table->integer('opt_md'); + $table->dropColumn(['zmodem','emsi_protocols','binkp','protocols','permissions']); + }); + + Schema::dropIfExists('node_system'); + Schema::dropIfExists('system_user'); + Schema::dropIfExists('systems'); + } +} diff --git a/public/oldschool/css/main.css b/public/oldschool/css/main.css index 6160379..32236d6 100644 --- a/public/oldschool/css/main.css +++ b/public/oldschool/css/main.css @@ -546,6 +546,9 @@ tbody { border-bottom:1px solid #666; color: #eee; } +.monotable tbody tr.admin { + color: #ff3333; +} .monotable tbody td { padding-left:1.5ch!important; padding-right:1.5ch!important; diff --git a/resources/views/auth/permissions.blade.php b/resources/views/auth/permissions.blade.php new file mode 100644 index 0000000..237636b --- /dev/null +++ b/resources/views/auth/permissions.blade.php @@ -0,0 +1,46 @@ +@extends('layouts.app') +@section('htmlheader_title') + Permissions for {{ auth()->check() ? auth()->user()->name : 'Guest' }} +@endsection + +@section('content') +
Test | +Result | +||||
---|---|---|---|---|---|
isAdmin | +@can('admin')YES @else NO @endcan | +||||
Domains | +
+
|
+
In FTN network addresses, a domain is the 5th dimension and used when a system supports 5D addressing, ie: zone:hub/host@domain.
Domains are used with zones to uniquely identify a FTN network.
Some legacy Fidonet software is not 5D aware and may behave unexpectedly when a domain is used
@@ -18,28 +18,34 @@This system is aware of the following domains:
@if (\App\Models\Domain::count() == 0) -There are no domains setup, to set up your first.
+ @can('admin',(new \App\Models\Domain)) +There are no domains setup, to set up your first.
+ @else +There are no domains - you need to ask an admin to create one for you.
+ @endcan @elseID | -Active | Domain | +Active | DNS domain | Zones |
---|---|---|---|---|---|
Add New Domain | |||||
{{ $oo->id }} | -{{ $oo->active ? 'YES' : 'NO' }} | {{ $oo->name }} | +{{ $oo->active ? 'YES' : 'NO' }} | {{ $oo->dnsdomain }} | {{ join(', ',$oo->zones->pluck('zone_id')->toArray()) }} |
ID | +System | +Sysop | +Location | +Active | +Connect | +
---|---|---|---|---|---|
Add New System | +|||||
{{ $oo->id }} | +{{ $oo->name }} | +{{ $oo->sysop }} | +{{ $oo->location }} | +{{ $oo->active ? 'YES' : 'NO' }} | ++ @switch($oo->method) + @case(23)Telnet@break + @case(22)SSH@break + @case(519)SSH@break + @default No details + @endswitch + | +
Current Users:
+ID | +Name | +Verified | +Last On | +|
---|---|---|---|---|
Add New User | +||||
{{ $oo->id }} | +{{ $oo->email }} | +{{ $oo->name }} | +{{ $oo->email_verified_at ? $oo->email_verified_at->format('Y-m-d') : '-' }} | +{{-- $oo->last_on --}}TBA | +