Adjustments for Misuzu support.
This commit is contained in:
parent
44052291b1
commit
e74e6b1711
2 changed files with 17 additions and 4 deletions
|
@ -39,8 +39,12 @@ $router->use('/', function($response, $request) {
|
||||||
|
|
||||||
if($isApiDomain) {
|
if($isApiDomain) {
|
||||||
$router->use('/', function($response, $request) {
|
$router->use('/', function($response, $request) {
|
||||||
if($request->getMethod() === 'OPTIONS') {
|
if($request->hasHeader('Origin'))
|
||||||
$response->setHeader('Access-Control-Allow-Credentials', 'true');
|
$response->setHeader('Access-Control-Allow-Credentials', 'true');
|
||||||
|
});
|
||||||
|
|
||||||
|
$router->use('/', function($response, $request) {
|
||||||
|
if($request->getMethod() === 'OPTIONS') {
|
||||||
$response->setHeader('Access-Control-Allow-Headers', 'Authorization');
|
$response->setHeader('Access-Control-Allow-Headers', 'Authorization');
|
||||||
$response->setHeader('Access-Control-Allow-Methods', 'OPTIONS, GET, POST, DELETE');
|
$response->setHeader('Access-Control-Allow-Methods', 'OPTIONS, GET, POST, DELETE');
|
||||||
return 204;
|
return 204;
|
||||||
|
@ -49,6 +53,12 @@ if($isApiDomain) {
|
||||||
|
|
||||||
$router->use('/', function($response, $request) use ($db) {
|
$router->use('/', function($response, $request) use ($db) {
|
||||||
$auth = $request->getHeaderLine('Authorization');
|
$auth = $request->getHeaderLine('Authorization');
|
||||||
|
if(empty($auth)) {
|
||||||
|
$mszAuth = (string)$request->getCookie('msz_auth');
|
||||||
|
if(!empty($mszAuth))
|
||||||
|
$auth = 'Misuzu ' . $mszAuth;
|
||||||
|
}
|
||||||
|
|
||||||
if(!empty($auth)) {
|
if(!empty($auth)) {
|
||||||
$authParts = explode(' ', $auth, 2);
|
$authParts = explode(' ', $auth, 2);
|
||||||
$authMethod = strval($authParts[0] ?? '');
|
$authMethod = strval($authParts[0] ?? '');
|
||||||
|
|
|
@ -59,8 +59,9 @@ EEPROM.EEPROMFile = function(fileInfo) {
|
||||||
};
|
};
|
||||||
|
|
||||||
obj.isImage = function() { return obj.type.indexOf('image/') === 0; };
|
obj.isImage = function() { return obj.type.indexOf('image/') === 0; };
|
||||||
obj.isAudio = function() { return obj.type.indexOf('audio/') === 0; };
|
obj.isAudio = function() { return obj.type === 'application/x-font-gdos' || obj.type.indexOf('audio/') === 0; };
|
||||||
obj.isVideo = function() { return obj.type.indexOf('video/') === 0; };
|
obj.isVideo = function() { return obj.type.indexOf('video/') === 0; };
|
||||||
|
obj.isMedia = function() { return obj.isImage() || obj.isAudio() || obj.isVideo(); };
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
};
|
};
|
||||||
|
@ -109,7 +110,8 @@ EEPROM.EEPROMDeleteTask = function(authorization, fileInfo) {
|
||||||
|
|
||||||
obj.start = function() {
|
obj.start = function() {
|
||||||
xhr.open('DELETE', obj.fileInfo.urlf);
|
xhr.open('DELETE', obj.fileInfo.urlf);
|
||||||
xhr.setRequestHeader('Authorization', obj.authorization);
|
if(obj.authorization) xhr.setRequestHeader('Authorization', obj.authorization);
|
||||||
|
else xhr.withCredentials = true;
|
||||||
xhr.send();
|
xhr.send();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -202,7 +204,8 @@ EEPROM.EEPROMUploadTask = function(srcId, endpoint, authorization, file) {
|
||||||
|
|
||||||
obj.start = function() {
|
obj.start = function() {
|
||||||
xhr.open('POST', obj.endpoint);
|
xhr.open('POST', obj.endpoint);
|
||||||
xhr.setRequestHeader('Authorization', obj.authorization);
|
if(obj.authorization) xhr.setRequestHeader('Authorization', obj.authorization);
|
||||||
|
else xhr.withCredentials = true;
|
||||||
xhr.send(fd);
|
xhr.send(fd);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue