-
-
Notifications
You must be signed in to change notification settings - Fork 663
Expand file tree
/
Copy pathGetAuthConfigAction.php
More file actions
30 lines (25 loc) · 912 Bytes
/
Copy pathGetAuthConfigAction.php
File metadata and controls
30 lines (25 loc) · 912 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
namespace HiEvents\Http\Actions\Auth;
use Illuminate\Http\JsonResponse;
class GetAuthConfigAction extends BaseAuthAction
{
public function __invoke(): JsonResponse
{
$providersStr = env('AUTH_PROVIDERS', '');
$providerKeys = empty($providersStr)
? []
: array_values(array_filter(array_map('trim', explode(',', $providersStr))));
$providers = array_map(function ($key) {
$upperKey = strtoupper($key);
return [
'id' => $key,
'name' => ucfirst($key),
'logo_url' => env("AUTH_{$upperKey}_LOGO_URL", null),
];
}, $providerKeys);
return response()->json([
'auth_disable_default' => env('AUTH_DISABLE_DEFAULT', false) === 'true' || env('AUTH_DISABLE_DEFAULT', false) === true,
'auth_providers' => $providers
]);
}
}