User register system, minor cosmetic changes, start of user authorisation
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
@@ -57,4 +57,9 @@ class UserController extends Controller
|
||||
{
|
||||
return view('user.home');
|
||||
}
|
||||
|
||||
public function register()
|
||||
{
|
||||
return view('user/system/register');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user