Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammad-Alavi committed Oct 10, 2021
1 parent 724ecf8 commit b57f6b9
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand All @@ -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;
}
}

0 comments on commit b57f6b9

Please sign in to comment.