Extend CORS headers to include X-Customer-Number and add customer context in subuser grants.
This commit is contained in:
+2
-2
@@ -52,14 +52,14 @@ http {
|
||||
location / {
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";
|
||||
add_header Access-Control-Allow-Headers "Authorization, Content-Type, X-Requested-With";
|
||||
add_header Access-Control-Allow-Headers "Authorization, Content-Type, X-Requested-With, X-Customer-Number";
|
||||
add_header Access-Control-Allow-Credentials true;
|
||||
|
||||
# If OPTIONS method is needed for preflight
|
||||
if ($request_method = 'OPTIONS') {
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";
|
||||
add_header Access-Control-Allow-Headers "Authorization, Content-Type, X-Requested-With";
|
||||
add_header Access-Control-Allow-Headers "Authorization, Content-Type, X-Requested-With, X-Customer-Number";
|
||||
return 204; # No Content
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ if ($DEBUG) {
|
||||
|
||||
/** CORS */
|
||||
header("Access-Control-Allow-Origin: $CORS");
|
||||
header("Access-Control-Allow-Headers: Content-Type, Authorization");
|
||||
header("Access-Control-Allow-Headers: Content-Type, Authorization, X-Customer-Number");
|
||||
header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS");
|
||||
|
||||
/** Autoload */
|
||||
|
||||
@@ -27,7 +27,7 @@ require_once 'twc_spreadsheet_class.php';
|
||||
// Set CORS headers
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
header("Access-Control-Allow-Methods: GET, POST");
|
||||
header("Access-Control-Allow-Headers: Content-Type");
|
||||
header("Access-Control-Allow-Headers: Content-Type, X-Customer-Number");
|
||||
|
||||
// Set the timezone
|
||||
date_default_timezone_set('Europe/Copenhagen');
|
||||
|
||||
@@ -577,6 +577,7 @@ class subusersRoute
|
||||
"phone" => $subuser->phone->value() !== null ? (int)$subuser->phone->value() : null,
|
||||
"grants" => array_map(function ($grant) {
|
||||
return [
|
||||
'name' => (new users_o())->getCustomerName((int)$grant['billing_customer_number']),
|
||||
'billing_customer_number' => (int)$grant['billing_customer_number'],
|
||||
'permissions' => json_decode($grant['permissions'], true) ?: [],
|
||||
];
|
||||
|
||||
@@ -61,13 +61,13 @@ http {
|
||||
|
||||
location ^~ / {
|
||||
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS, PUT, DELETE";
|
||||
add_header Access-Control-Allow-Headers "Authorization, Content-Type, X-Requested-With";
|
||||
add_header Access-Control-Allow-Headers "Authorization, Content-Type, X-Requested-With, X-Customer-Number";
|
||||
add_header Access-Control-Allow-Credentials true;
|
||||
|
||||
if ($request_method = 'OPTIONS') {
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS, PUT, DELETE";
|
||||
add_header Access-Control-Allow-Headers "Authorization, Content-Type, X-Requested-With";
|
||||
add_header Access-Control-Allow-Headers "Authorization, Content-Type, X-Requested-With, X-Customer-Number";
|
||||
return 204;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user