GWM : samul token issue
This commit is contained in:
parent
d0da0d7f96
commit
9fcb222db3
@ -5,6 +5,7 @@ namespace App\Controllers;
|
||||
use App\Models\SamlClientModel;
|
||||
use App\Helpers\JWTToken;
|
||||
use App\Helpers\RestAuthHelper;
|
||||
use App\Controllers\RestAuthenticationController;
|
||||
use OneLogin\Saml2\Auth as SamlAuth;
|
||||
use OneLogin\Saml2\Error as SamlError;
|
||||
use OneLogin\Saml2\Settings as SamlSettings;
|
||||
@ -189,14 +190,33 @@ class SamlController extends BaseController
|
||||
|
||||
$postEnrollment = ['status' => 'failed', 'code' => 404, 'data' => ''];
|
||||
if (! empty($empdata['post'])) {
|
||||
$postData = $empdata['post'];
|
||||
unset($postData['employee_id']);
|
||||
$postData['token_type'] = 'post';
|
||||
$postEnrollment = [
|
||||
'status' => 'success',
|
||||
'code' => 200,
|
||||
'data' => JWTToken::encode($postData),
|
||||
];
|
||||
$postId = $empdata['post']['id'] ?? $empdata['post']['employee_id'] ?? null;
|
||||
if ($postId !== null && $postId !== '') {
|
||||
$restAuth = new RestAuthenticationController();
|
||||
$endpoint = env('POST_ENROLLMENT_BASEURL', 'getTokenforSamulssOAuthLogin');
|
||||
$rawBody = $restAuth->callThirdPartyGETAPI(
|
||||
['id' => $postId],
|
||||
$endpoint
|
||||
);
|
||||
$api = is_string($rawBody) ? json_decode($rawBody, true) : null;
|
||||
if (is_array($api)
|
||||
&& (($api['status'] ?? '') === 'success' || (int) ($api['code'] ?? 0) === 200)
|
||||
&& isset($api['data'])
|
||||
&& $api['data'] !== ''
|
||||
) {
|
||||
$postEnrollment = [
|
||||
'status' => 'success',
|
||||
'code' => 200,
|
||||
'data' => is_string($api['data']) ? $api['data'] : (string) $api['data'],
|
||||
];
|
||||
} else {
|
||||
$postEnrollment = [
|
||||
'status' => 'failed',
|
||||
'code' => (int) ($api['code'] ?? 404),
|
||||
'data' => '',
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($empdata)) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user