append(':') ->append(AllowExternalProfileManagement::class) ->__toString(); $this->middleware(EnabledOnlyOnLocalhost::class); $this->middleware($isExternalProfileManagementAllowed); } /** * This will redirect the user to the appropriate auth service. * * @param Request $request * @return RedirectResponse|JsonResponse */ public function index(Request $request): RedirectResponse|JsonResponse { $validated = array_merge( $request->all(), [ExternalProfile::ATTRIBUTE_USER => Auth::id()] ); $site = Arr::get($validated, ExternalProfile::ATTRIBUTE_SITE); $profileSite = ExternalProfileSite::fromLocalizedName($site); if ($profileSite instanceof ExternalProfileSite) { $link = $profileSite->getAuthorizeUrl(); if ($link !== null) { return Redirect::to($link); } } return new JsonResponse([ 'error' => 'invalid site', ], 400); } }