You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.4 KiB
45 lines
1.4 KiB
<?php |
|
|
|
namespace App\Http\Controllers\Api\V1; |
|
|
|
use App\Http\Controllers\Api\Concerns\RespondsWithJson; |
|
use App\Http\Controllers\Controller; |
|
use App\Services\LdapAuthService; |
|
use App\Services\LdapMetadataService; |
|
use App\Support\ApiActor; |
|
use Illuminate\Http\JsonResponse; |
|
use Illuminate\Http\Request; |
|
|
|
class MeController extends Controller |
|
{ |
|
use RespondsWithJson; |
|
|
|
public function __construct( |
|
private readonly LdapAuthService $ldapAuth, |
|
private readonly LdapMetadataService $metadata, |
|
) { |
|
} |
|
|
|
public function show(Request $request): JsonResponse |
|
{ |
|
/** @var ApiActor $actor */ |
|
$actor = $request->attributes->get('api_actor'); |
|
|
|
$data = $actor->toArray(); |
|
|
|
// Untuk LDAP JWT — enrich dengan data profile dari LDAP + metadata DB |
|
if ($actor->type === 'ldap_jwt') { |
|
$profile = $this->ldapAuth->getProfile($actor->identifier); |
|
$meta = $this->metadata->getUserMeta($actor->identifier); |
|
|
|
$data['display_name'] = $profile['display_name'] ?? $actor->identifier; |
|
$data['email'] = $profile['email'] ?? ''; |
|
$data['last_logon'] = $profile['last_logon'] ?? null; |
|
$data['domain'] = $profile['domain'] ?? ''; |
|
$data['phone'] = $meta['phone'] ?? ''; |
|
$data['other_email'] = $meta['other_email'] ?? ''; |
|
} |
|
|
|
return $this->ok($data); |
|
} |
|
}
|
|
|