update all
This commit is contained in:
@@ -1,33 +1,34 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
require __DIR__ . '/_common.php';
|
||||
|
||||
require_login();
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
$o = read_store()['oauth'] ?? [];
|
||||
json_response(['ok' => true, 'oauth' => $o]);
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'PUT' && $_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
json_response(['ok' => false, 'error' => 'Use GET or PUT'], 405);
|
||||
}
|
||||
|
||||
$body = require_json_body();
|
||||
$store = read_store();
|
||||
$cur = $store['oauth'] ?? [];
|
||||
$keys = [
|
||||
'facebookAppId', 'facebookAppSecret', 'facebookRedirectUri',
|
||||
'googleClientId', 'googleClientSecret', 'googleRedirectUri',
|
||||
];
|
||||
foreach ($keys as $k) {
|
||||
if (array_key_exists($k, $body)) {
|
||||
$cur[$k] = trim((string)$body[$k]);
|
||||
}
|
||||
}
|
||||
$store['oauth'] = $cur;
|
||||
if (!write_store($store)) {
|
||||
json_response(['ok' => false, 'error' => 'บันทึกไม่สำเร็จ'], 500);
|
||||
}
|
||||
json_response(['ok' => true, 'oauth' => $cur]);
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
require __DIR__ . '/_common.php';
|
||||
|
||||
require_login();
|
||||
require_tab('oauth');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
$o = read_store()['oauth'] ?? [];
|
||||
json_response(['ok' => true, 'oauth' => $o]);
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'PUT' && $_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
json_response(['ok' => false, 'error' => 'Use GET or PUT'], 405);
|
||||
}
|
||||
|
||||
$body = require_json_body();
|
||||
$store = read_store();
|
||||
$cur = $store['oauth'] ?? [];
|
||||
$keys = [
|
||||
'facebookAppId', 'facebookAppSecret', 'facebookRedirectUri',
|
||||
'googleClientId', 'googleClientSecret', 'googleRedirectUri',
|
||||
];
|
||||
foreach ($keys as $k) {
|
||||
if (array_key_exists($k, $body)) {
|
||||
$cur[$k] = trim((string)$body[$k]);
|
||||
}
|
||||
}
|
||||
$store['oauth'] = $cur;
|
||||
if (!write_store($store)) {
|
||||
json_response(['ok' => false, 'error' => 'บันทึกไม่สำเร็จ'], 500);
|
||||
}
|
||||
json_response(['ok' => true, 'oauth' => $cur]);
|
||||
|
||||
Reference in New Issue
Block a user