More work on user linking to existing defined system

This commit is contained in:
Deon George
2022-12-04 13:30:38 +11:00
parent 14f28c5263
commit 05528f1c33
6 changed files with 133 additions and 17 deletions

View File

@@ -556,6 +556,29 @@ class SystemController extends Controller
return redirect()->to(sprintf('ftn/system/addedit/%d',$o->system_id));
}
public function system_link(Request $request)
{
if (! $request->system_id)
return redirect('user/system/register');
$s = Setup::findOrFail(config('app.id'))->system;
$so = System::findOrFail($request->system_id);
$ca = NULL;
$la = NULL;
foreach ($s->addresses as $ao) {
if ($ca=$so->match($ao->zone))
break;
}
if ($ca->count() && $la=$ca->pop())
Notification::route('netmail',$la)->notify(new AddressLink($la,Auth::user()));
return view('user.system.register_send')
->with('la',$la)
->with('o',$so);
}
/**
* register system
*/
@@ -565,6 +588,10 @@ class SystemController extends Controller
if ($request->isMethod('GET'))
return view('user.system.register');
if ($request->action != 'create')
return view('user.system.widget.register_confirm')
->with('o',System::findOrFail($request->system_id));
$o = System::findOrNew($request->system_id);
// If the system exists, and we are 'register', we'll start the address claim process
@@ -575,7 +602,7 @@ class SystemController extends Controller
if ($validate->count())
Notification::route('netmail',$x=$validate->first())->notify(new AddressLink($x,Auth::user()));
return view('user.system.widget.register_confirm')
return view('user.system.widget.register_send')
->with('validate',$validate)
->with('o',$o);
}