Issue PWA auth during launcher PIN login
This commit is contained in:
1 parent
71731245de
commit
21486b606b
2 files changed
+28
-6
No files matched your search
@@ -7,7 +7,7 @@ header('Content-Type: application/json; charset=utf-8');
|
||||
header('Cache-Control: no-store');
|
||||
|
||||
$origin = (string)($_SERVER['HTTP_ORIGIN'] ?? '');
|
||||
if (preg_match('#^https://([a-z0-9-]+\.)?chaegeon\.com$#i', $origin) === 1) {
|
||||
if ($origin === 'https://chaegeon.com') {
|
||||
header('Access-Control-Allow-Origin: ' . $origin);
|
||||
header('Access-Control-Allow-Credentials: true');
|
||||
header('Access-Control-Allow-Headers: Content-Type, X-Requested-With');
|
||||
@@ -28,6 +28,8 @@ function launcher_is_digit_password(string $password): bool
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
custom_block_login_denied(true);
|
||||
|
||||
$data = custom_read_request_data();
|
||||
$action = $data['action'] ?? 'login';
|
||||
|
||||
@@ -39,7 +41,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
|
||||
if (custom_verify_password($password)) {
|
||||
custom_issue_auth_cookie(false);
|
||||
custom_json(['result' => 'ok']);
|
||||
$pwaService = (string)($data['pwaService'] ?? $_GET['pwaService'] ?? '');
|
||||
$pwaIssued = $pwaService !== '' && function_exists('custom_issue_pwa_auth_cookie')
|
||||
? custom_issue_pwa_auth_cookie($pwaService)
|
||||
: false;
|
||||
custom_json(['result' => 'ok', 'pwaIssued' => $pwaIssued]);
|
||||
}
|
||||
|
||||
custom_json(['result' => 'fail'], 401);
|
||||
@@ -99,14 +105,30 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
|
||||
if (custom_is_site_admin()) {
|
||||
custom_issue_auth_cookie(true);
|
||||
custom_json(['authenticated' => true, 'admin' => true]);
|
||||
$pwaService = (string)($_GET['pwaService'] ?? '');
|
||||
custom_json([
|
||||
'authenticated' => true,
|
||||
'admin' => true,
|
||||
'pwaAuthenticated' => $pwaService !== '' && function_exists('custom_has_pwa_auth_cookie') && custom_has_pwa_auth_cookie($pwaService),
|
||||
]);
|
||||
}
|
||||
|
||||
if (custom_has_auth_cookie()) {
|
||||
custom_json(['authenticated' => true, 'admin' => false]);
|
||||
$pwaService = (string)($_GET['pwaService'] ?? '');
|
||||
custom_json([
|
||||
'authenticated' => true,
|
||||
'admin' => false,
|
||||
'pwaAuthenticated' => $pwaService !== '' && function_exists('custom_has_pwa_auth_cookie') && custom_has_pwa_auth_cookie($pwaService),
|
||||
]);
|
||||
}
|
||||
|
||||
custom_json(['authenticated' => false, 'admin' => false]);
|
||||
$pwaService = (string)($_GET['pwaService'] ?? '');
|
||||
$pwaAuthenticated = $pwaService !== '' && function_exists('custom_has_pwa_auth_cookie') && custom_has_pwa_auth_cookie($pwaService);
|
||||
custom_json([
|
||||
'authenticated' => false,
|
||||
'admin' => false,
|
||||
'pwaAuthenticated' => $pwaAuthenticated,
|
||||
]);
|
||||
}
|
||||
|
||||
if (isset($_GET['adminSession'])) {
|
||||
|
||||
Reference in new issue
Block a user