From b57f6b9d37d13a4870b6d01be4cc9fb85c705eb1 Mon Sep 17 00:00:00 2001 From: mohammad-alavi Date: Sun, 10 Oct 2021 12:15:05 +0330 Subject: [PATCH] refactor --- .../Actions/ApiLoginProxyForWebClientAction.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) 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; + } }