auth()->user()->id, 'company_key'=> auth()->user()->company()->company_key, 'context' => $request->input('context'), ]; Cache::put($hash, $data, 3600); return response()->json(['hash' => $hash], 200); } public function router(OneTimeRouterRequest $request) { $data = Cache::get($request->input('hash')); MultiDB::findAndSetDbByCompanyKey($data['company_key']); // $user = User::findOrFail($data['user_id']); // Auth::login($user, true); // Cache::forget($request->input('hash')); $this->sendTo($data['context']); } /* We need to merge all contexts here and redirect to the correct location */ private function sendTo($context) { return redirect(); } }