diff --git a/app/Http/Controllers/SystemController.php b/app/Http/Controllers/SystemController.php
index e8f0f7f..158db4c 100644
--- a/app/Http/Controllers/SystemController.php
+++ b/app/Http/Controllers/SystemController.php
@@ -3,8 +3,11 @@
namespace App\Http\Controllers;
use Carbon\Carbon;
+use Illuminate\Database\Eloquent\Collection;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
+use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\ViewErrorBag;
use App\Models\{Address,Echoarea,System,SystemZone,Zone};
use App\Rules\{FidoInteger,TwoByteInteger};
@@ -284,6 +287,19 @@ class SystemController extends Controller
->with('o',$o);
}
+ /**
+ * Systems with no owners
+ */
+ public function api_orphan(Request $request): Collection
+ {
+ return System::select(['id','name'])
+ ->leftjoin('system_user',['system_user.system_id'=>'systems.id'])
+ ->whereNull('user_id')
+ ->where('systems.name','ilike','%'.$request->term.'%')
+ ->orderBy('name')
+ ->get();
+ }
+
/**
* Delete address assigned to a host
*
@@ -356,6 +372,11 @@ class SystemController extends Controller
->with('echoareas',$eo);
}
+ public function home()
+ {
+ return view('system.home');
+ }
+
/**
* Move address to another system
*
@@ -424,8 +445,33 @@ class SystemController extends Controller
return redirect()->to(sprintf('ftn/system/addedit/%d',$o->system_id));
}
- public function home()
+ /**
+ * register system
+ */
+ public function system_register(Request $request)
{
- return view('system.home');
+ $o = System::findOrNew($request->system_id);
+
+ if (! $o->exist) {
+ $o->sysop = Auth::user()->name;
+
+ foreach (['name','zt_id','location','mailer_type','mailer_address','mailer_port','phone','method','address','port'] as $item)
+ if ($request->{$item})
+ $o->{$item} = $request->{$item};
+
+ $o->active = TRUE;
+ }
+
+ if ($request->post('submit')) {
+ Auth::user()->systems()->save($o);
+
+ // @todo if the system already exists and part of one of our nextworks, we'll need to send the registration email to confirm the address.
+ // @todo mark the system (or addresses) as "pending" at this stage until it is confirmed
+ return redirect()->to(url('ftn/system/addedit',$o->id));
+ }
+
+ return view('system.widget.form-system')
+ ->with('o',$o)
+ ->with('errors',new ViewErrorBag);
}
}
diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php
index 3377868..b2095cc 100644
--- a/app/Http/Controllers/UserController.php
+++ b/app/Http/Controllers/UserController.php
@@ -57,4 +57,9 @@ class UserController extends Controller
{
return view('user.home');
}
+
+ public function register()
+ {
+ return view('user/system/register');
+ }
}
diff --git a/app/Policies/SystemPolicy.php b/app/Policies/SystemPolicy.php
new file mode 100644
index 0000000..864e51c
--- /dev/null
+++ b/app/Policies/SystemPolicy.php
@@ -0,0 +1,24 @@
+exists) || $system->users->contains($user) || $user->isAdmin();
+ }
+}
\ No newline at end of file
diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php
index f1048e4..31fa335 100644
--- a/app/Providers/AuthServiceProvider.php
+++ b/app/Providers/AuthServiceProvider.php
@@ -15,7 +15,7 @@ class AuthServiceProvider extends ServiceProvider
* @var array
*/
protected $policies = [
- 'App\Model' => 'App\Policies\ModelPolicy',
+ //'App\Model' => 'App\Policies\ModelPolicy',
];
/**
diff --git a/public/oldschool/css/main.css b/public/oldschool/css/main.css
index a64bd81..d6c938e 100644
--- a/public/oldschool/css/main.css
+++ b/public/oldschool/css/main.css
@@ -404,9 +404,7 @@ ul#searchbar li i {
content:"\2666\a0\A0";
color:#0a0
}
-#content ul ul li::before {
- content:"\25CB\A0\A0"!important
-}
+
#content ul li:last-child {
margin-bottom: 16px;
}
@@ -488,6 +486,7 @@ form div.row {
margin-top:1em
}
.greyframe>div.row:last-child,
+.greyframe>div>div.row:last-child,
.greyframe>form>div.row:last-child {
padding-bottom: 15px;
}
diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard.blade.php
index ea58eec..fd7b431 100644
--- a/resources/views/dashboard.blade.php
+++ b/resources/views/dashboard.blade.php
@@ -51,7 +51,7 @@
@else
-
You are not linked to any BBS systems.
+ You are not linked to any BBS systems. Start here to link to your first.
@endif
@endsection
diff --git a/resources/views/layouts/partials/htmlheader.blade.php b/resources/views/layouts/partials/htmlheader.blade.php
index b9c090b..3ed9656 100644
--- a/resources/views/layouts/partials/htmlheader.blade.php
+++ b/resources/views/layouts/partials/htmlheader.blade.php
@@ -10,7 +10,7 @@
-
+
diff --git a/resources/views/system/addedit.blade.php b/resources/views/system/addedit.blade.php
index e0afa88..de2d086 100644
--- a/resources/views/system/addedit.blade.php
+++ b/resources/views/system/addedit.blade.php
@@ -1,7 +1,7 @@
@extends('layouts.app')
@section('htmlheader_title')
- @if($o->exists) Update @else Add @endif System
+ @can('admin',$o) @if($o->exists) Update @else Add @endif @endcan System
@endsection
@php
diff --git a/resources/views/system/form-system.blade.php b/resources/views/system/form-system.blade.php
index 13a9ac1..13aedc7 100644
--- a/resources/views/system/form-system.blade.php
+++ b/resources/views/system/form-system.blade.php
@@ -8,196 +8,9 @@
-
@if($o->exists) Update @else Add @endif System
+
@can('update',$o) @if($o->exists) Update @else Add @endif @endif System
-
-
-
-
Name
-
-
-
-
- @error('name')
- {{ $message }}
- @else
- A name is required.
- @enderror
-
-
-
-
-
-
-
-
-
-
ZeroTier ID
-
-
-
-
- @error('zt_id')
- {{ $message }}
- @enderror
-
-
-
-
-
-
-
-
-
Sysop
-
-
-
-
- @error('sysop')
- {{ $message }}
- @else
- A Sysop's name is required.
- @enderror
-
-
-
-
-
-
-
Location
-
-
-
-
- @error('location')
- {{ $message }}
- @else
- System location is required.
- @enderror
-
-
-
-
-
-
-
-
-
Mailer Details
-
-
-
-
Connection Method
-
-
-
-
- mailer_type) == Setup::O_BINKP)selected @endif}}>BINKP
- mailer_type) == Setup::O_EMSI)selected @endif}}>EMSI
-
-
-
-
-
-
-
-
-
-
Phone
-
-
-
-
- @error('phone')
- {{ $message }}
- @enderror
-
-
-
-
-
-
-
-
-
-
-
BBS Details
-
-
-
-
Connection Method
-
-
-
-
- method) == 23)selected @endif}}>Telnet
- method) == 22)selected @endif}}>SSH
- method) == 519)selected @endif}}>Rlogin
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Cancel
- @can('admin',$o)
-
@if ($o->exists)Save @else Add @endif
- @endcan
-
-
+ @include('system.widget.form-system')
diff --git a/resources/views/system/widget/echoarea.blade.php b/resources/views/system/widget/echoarea.blade.php
index 1bd5265..cf5b156 100644
--- a/resources/views/system/widget/echoarea.blade.php
+++ b/resources/views/system/widget/echoarea.blade.php
@@ -28,13 +28,13 @@
- @if($errors->count())
+ @if($errors->count())
- There were errors with the submission.
- @dump($errors)
-
+ There were errors with the submission.
+ @dump($errors)
+
@endif
-
+
@can('admin',$o)
diff --git a/resources/views/system/widget/form-system.blade.php b/resources/views/system/widget/form-system.blade.php
new file mode 100644
index 0000000..903a2a9
--- /dev/null
+++ b/resources/views/system/widget/form-system.blade.php
@@ -0,0 +1,206 @@
+@php
+ use App\Models\Setup;
+@endphp
+
+
+
+
+
Name
+
+
+
+
+ @error('name')
+ {{ $message }}
+ @else
+ A name is required.
+ @enderror
+
+
+
+
+
+
+ @if($o->exists)
+ @can('admin',$o)
+
Active
+
+ @endcan
+ @endif
+
+
+
+
+
ZeroTier ID
+
+
+
+
+ @error('zt_id')
+ {{ $message }}
+ @enderror
+
+
+
+
+
+
+
+
+
Sysop
+
+
+
+
+ @error('sysop')
+ {{ $message }}
+ @else
+ A Sysop's name is required.
+ @enderror
+
+
+
+
+
+
+
Location
+
+
+
+
+ @error('location')
+ {{ $message }}
+ @else
+ System location is required.
+ @enderror
+
+
+
+
+
+
+
+
+
Mailer Details
+
+
+
+
Connection Method
+
+
+
+
+ mailer_type) == Setup::O_BINKP)selected @endif>BINKP
+ mailer_type) == Setup::O_EMSI)selected @endif>EMSI
+
+
+
+
+
+
+
+
+
+
Phone
+
+
+
+
+ @error('phone')
+ {{ $message }}
+ @enderror
+
+
+
+
+
+
+
+
+
+
+
BBS Details
+
+
+
+
Connection Method
+
+
+
+
+ method) == 23)selected @endif>Telnet
+ method) == 22)selected @endif>SSH
+ method) == 519)selected @endif>Rlogin
+
+
+
+
+
+
+
+
+
+@can('admin',$o)
+
+@endcan
+
+
+
+ @if($o->exists)
+ @can('update',$o)
+
Cancel
+
@if ($o->exists)Save @else Add @endif
+ @else
+
+
NOTE: You'll be able to update these details after registration is completed.
+
Register
+ @endcan
+ @else
+
Register
+ @endif
+
+
\ No newline at end of file
diff --git a/resources/views/user/system/register.blade.php b/resources/views/user/system/register.blade.php
new file mode 100644
index 0000000..1d31261
--- /dev/null
+++ b/resources/views/user/system/register.blade.php
@@ -0,0 +1,185 @@
+@extends('layouts.app')
+
+@section('htmlheader_title')
+ Register System
+@endsection
+
+@section('content')
+
+@endsection
+
+@section('page-css')
+
+@append
+@section('page-scripts')
+
+@append
\ No newline at end of file
diff --git a/resources/views/zone/addedit.blade.php b/resources/views/zone/addedit.blade.php
index ebfe44f..9c4b97c 100644
--- a/resources/views/zone/addedit.blade.php
+++ b/resources/views/zone/addedit.blade.php
@@ -146,10 +146,10 @@
@error('zt_ipv6')
- {{ $message }}
+ {{ $message }}
@enderror
@error('zt_ipv6_mask')
- {{ $message }}
+ {{ $message }}
@enderror
diff --git a/routes/api.php b/routes/api.php
index 85be738..ae671dd 100644
--- a/routes/api.php
+++ b/routes/api.php
@@ -2,7 +2,7 @@
use Illuminate\Support\Facades\Route;
-use App\Http\Controllers\{DomainController,ZoneController};
+use App\Http\Controllers\{DomainController,SystemController,ZoneController};
/*
|--------------------------------------------------------------------------
@@ -18,6 +18,7 @@ use App\Http\Controllers\{DomainController,ZoneController};
Route::middleware(['auth:api'])->group(function () {
Route::get('regions/{o}',[DomainController::class,'api_regions']);
Route::get('hosts/{o}/{region}',[DomainController::class,'api_hosts']);
+ Route::get('systems/orphan',[SystemController::class,'api_orphan']);
Route::get('hubs/{o}/{host}',[DomainController::class,'api_hubs']);
Route::post('default/{o}',[ZoneController::class,'api_default']);
});
diff --git a/routes/web.php b/routes/web.php
index db02ea7..be33835 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -81,6 +81,9 @@ Route::middleware(['verified','activeuser'])->group(function () {
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('user/system/register',[UserController::class,'register']);
+ Route::post('user/system/register',[SystemController::class,'system_register']);
});
Route::get('network/{o}',[HomeController::class,'network']);