post()) { $this->authorize('admin',$o); $request->validate([ 'email' => 'required|email|unique:users,email,'.($o->exists ? $o->id : 0), 'name' => 'required|min:3', 'pgp_pubkey' => [ 'nullable', 'min:64', //function ($attribute,$value,$fail) { return $fail('Not this time'); } ], 'alias' => 'nullable|min:1', 'active' => 'required|boolean', 'admin' => 'required|boolean', ]); foreach (['name','email','pgp_pubkey','active','admin','alias'] as $key) $o->{$key} = $request->post($key); if (! $o->exists) $o->password = base64_encode(random_bytes(20)); $o->save(); if ($o->wasRecentlyCreated) event(new Registered($o)); return redirect()->action([self::class,'home']); } return view('user.addedit') ->with('o',$o); } public function dashboard() { $user = Auth::user(); $user->load('systems.addresses.zone.domain.echoareas'); return view('dashboard') ->with('user',$user); } public function home() { return view('user.home'); } public function link(Request $request) { if ($request->post()) { $request->validate([ 'address_id'=>'required|exists:addresses,id', 'code'=>'required:string', ]); $ao = Address::findOrFail($request->address_id); if ($ao->check_activation(Auth::user(),$request->code)) { $ao->validated = TRUE; $ao->save(); $ao->system->users()->save(Auth::user()); return redirect()->to('/'); } else { $validator = Validator::make([],[]); $validator->errors()->add( 'code', 'Invalid Code!' ); return back()->withErrors($validator); } } return view('user.link'); } public function register() { return view('user/system/register'); } }