diff --git a/app/Containers/AppSection/Authentication/Actions/ApiLoginProxyForWebClientAction.php b/app/Containers/AppSection/Authentication/Actions/ApiLoginProxyForWebClientAction.php index 67030d3d3..79563ce72 100644 --- a/app/Containers/AppSection/Authentication/Actions/ApiLoginProxyForWebClientAction.php +++ b/app/Containers/AppSection/Authentication/Actions/ApiLoginProxyForWebClientAction.php @@ -24,12 +24,7 @@ public function run(LoginProxyPasswordGrantRequest $request): array ); $loginCustomAttribute = app(ExtractLoginCustomAttributeTask::class)->run($sanitizedData); - - $sanitizedData['username'] = $loginCustomAttribute['username']; - $sanitizedData['client_id'] = config('appSection-authentication.clients.web.id'); - $sanitizedData['client_secret'] = config('appSection-authentication.clients.web.secret'); - $sanitizedData['grant_type'] = 'password'; - $sanitizedData['scope'] = ''; + $sanitizedData = $this->enrichSanitizedData($loginCustomAttribute['username'], $sanitizedData); $responseContent = app(CallOAuthServerTask::class)->run($sanitizedData, $request->headers->get('accept-language')); $refreshCookie = app(MakeRefreshCookieTask::class)->run($responseContent['refresh_token']); @@ -39,4 +34,14 @@ public function run(LoginProxyPasswordGrantRequest $request): array 'refresh_cookie' => $refreshCookie, ]; } + + private function enrichSanitizedData($username, array $sanitizedData): array + { + $sanitizedData['username'] = $username; + $sanitizedData['client_id'] = config('appSection-authentication.clients.web.id'); + $sanitizedData['client_secret'] = config('appSection-authentication.clients.web.secret'); + $sanitizedData['grant_type'] = 'password'; + $sanitizedData['scope'] = ''; + return $sanitizedData; + } }