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') +

{{ auth()->check() ? auth()->user()->name : 'Guest' }}

+ + + + + + + + + + + + + + + + + + + +
TestResult
isAdmin@can('admin')YES @else NO @endcan
Domains + + + + + + + + + + @foreach (\App\Models\Domain::orderBy('name')->get() as $o) + + + + + @endforeach + +
DomainResult
{{ $o->name }}@can('admin',$o)YES @else NO @endcan
+
+@endsection diff --git a/resources/views/domain/addedit.blade.php b/resources/views/domain/addedit.blade.php index 82b7eba..a572d6a 100644 --- a/resources/views/domain/addedit.blade.php +++ b/resources/views/domain/addedit.blade.php @@ -35,10 +35,10 @@
- active)checked @endif> + active))checked @endif> - active)checked @endif> + active))checked @endif>
@@ -47,7 +47,7 @@
- +
@@ -63,17 +63,14 @@
- public)checked @endif> + public))checked @endif> - public)checked @endif> + public))checked @endif>
-
- more text -
diff --git a/resources/views/domain/home.blade.php b/resources/views/domain/home.blade.php index cf19150..fc4da50 100644 --- a/resources/views/domain/home.blade.php +++ b/resources/views/domain/home.blade.php @@ -6,7 +6,7 @@ @section('content')
-

About the FTN Clearing House

+

About FTN 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 @else - + + @can('admin',(new \App\Models\Domain())) + @endcan @foreach (\App\Models\Domain::orderBy('name')->cursor() as $oo) - + diff --git a/resources/views/errors/403.blade.php b/resources/views/errors/403.blade.php new file mode 100644 index 0000000..8e40411 --- /dev/null +++ b/resources/views/errors/403.blade.php @@ -0,0 +1,15 @@ +@extends('layouts.auth') + +@section('htmlheader_title') + 403 +@endsection + +@section('content') +
+
+

403 - Not allowed

+

Sorry, it appears you are not allowed to do that.

+

Home

+
+
+@endsection \ No newline at end of file diff --git a/resources/views/layouts/partials/sidebar.blade.php b/resources/views/layouts/partials/sidebar.blade.php index 7f72571..8349a43 100644 --- a/resources/views/layouts/partials/sidebar.blade.php +++ b/resources/views/layouts/partials/sidebar.blade.php @@ -4,6 +4,7 @@
Network Admin
Domains
+
Systems
Zones
Nodes
diff --git a/resources/views/setup.blade.php b/resources/views/setup.blade.php new file mode 100644 index 0000000..8e79b6a --- /dev/null +++ b/resources/views/setup.blade.php @@ -0,0 +1,8 @@ +@extends('layouts.app') +@section('htmlheader_title') + Setup +@endsection + +@section('content') +

Site Setup

+@endsection diff --git a/resources/views/system/home.blade.php b/resources/views/system/home.blade.php new file mode 100644 index 0000000..e3b4c53 --- /dev/null +++ b/resources/views/system/home.blade.php @@ -0,0 +1,76 @@ +@extends('layouts.app') +@section('htmlheader_title') + Systems +@endsection + +@section('content') +
+
+

BBS Systems

+

BBS Systems Send and Receive Echomail and Files.

+
+
+ +
+
+

This system is aware of the following systems:

+ + @if (\App\Models\System::count() == 0) + @can('admin',(new \App\Models\System)) +

There are no systems setup, to set up your first.

+ @else +

There are no systems - you need to ask an admin to create one for you.

+ @endcan + @else +
IDActive DomainActive 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()) }}
+ + + + + + + + + + + + + @can('admin',(new \App\Models\System)) + + + + @endcan + @foreach (\App\Models\System::orderBy('name')->cursor() as $oo) + + + + + + + + + @endforeach + +
IDSystemSysopLocationActiveConnect
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 +
+ @endif +
+
+@endsection + +@section('page-scripts') + +@append diff --git a/resources/views/user/home.blade.php b/resources/views/user/home.blade.php new file mode 100644 index 0000000..5153bef --- /dev/null +++ b/resources/views/user/home.blade.php @@ -0,0 +1,51 @@ +@extends('layouts.app') +@section('htmlheader_title') + Users +@endsection + +@section('content') +
+
+

Current Users:

+ + + + + + + + + + + + + @can('admin',(new \App\Models\Domain())) + + + + @endcan + @foreach (\App\Models\User::orderBy('email')->cursor() as $oo) + + + + + + + + @endforeach + +
IDEmailNameVerifiedLast 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
+
+
+@endsection + +@section('page-scripts') + +@append diff --git a/routes/web.php b/routes/web.php index f7988a2..5f9b6d9 100644 --- a/routes/web.php +++ b/routes/web.php @@ -3,7 +3,7 @@ use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Route; -use App\Http\Controllers\{HomeController,DomainController,NodeController,ZoneController}; +use App\Http\Controllers\{HomeController,DomainController,NodeController,SystemController,UserController,ZoneController}; use App\Http\Controllers\Auth\LoginController; /* @@ -39,13 +39,20 @@ Route::middleware(['verified'])->group(function () { Route::match(['get','post'],'ftn/node/addedit/{o?}',[NodeController::class,'add_edit']) ->where('o','[0-9]+'); + Route::get('ftn/system',[SystemController::class,'home']); + Route::match(['get','post'],'ftn/system/addedit/{o?}',[SystemController::class,'add_edit']) + ->where('o','[0-9]+'); + Route::get('ftn/zone',[ZoneController::class,'home']); Route::match(['get','post'],'ftn/zone/addedit/{o?}',[ZoneController::class,'add_edit']) ->where('o','[0-9]+'); }); Route::get('network/{o}',[HomeController::class,'network']); +Route::get('permissions',[HomeController::class,'permissions']); Route::middleware(['auth','can:admin'])->group(function () { Route::get('setup',[HomeController::class,'setup']); + + Route::get('user/list',[UserController::class,'home']); }); \ No newline at end of file