-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfigController.php
More file actions
37 lines (31 loc) · 903 Bytes
/
ConfigController.php
File metadata and controls
37 lines (31 loc) · 903 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
31
32
33
34
35
36
37
<?php
namespace TransformStudios\Front\Http\Controllers;
use Illuminate\Http\JsonResponse;
use Statamic\Facades\User;
class ConfigController
{
public function __invoke(): JsonResponse
{
$email = null;
$hash = null;
$name = null;
if ($user = User::current()) {
$email = $user->email();
$hash = hash_hmac('sha256', $email, config('front.secret_key'));
$name = $user->get('name');
}
return response()->json([
'configured' => $this->isConfigured(),
'chatId' => config('front.chat.id'),
'email' => $email,
'name' => $name,
'hash' => $hash,
]);
}
private function isConfigured(): bool
{
return config('front.chat.show_on_front_end') &&
config('front.chat.id') &&
config('front.secret_key');
}
}