Adjustments for Misuzu support.

This commit is contained in:
Pachira 2023-03-09 21:04:43 +00:00
parent 44052291b1
commit e74e6b1711
2 changed files with 17 additions and 4 deletions

View file

@ -39,8 +39,12 @@ $router->use('/', function($response, $request) {
if($isApiDomain) {
$router->use('/', function($response, $request) {
if($request->getMethod() === 'OPTIONS') {
if($request->hasHeader('Origin'))
$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-Methods', 'OPTIONS, GET, POST, DELETE');
return 204;
@ -49,6 +53,12 @@ if($isApiDomain) {
$router->use('/', function($response, $request) use ($db) {
$auth = $request->getHeaderLine('Authorization');
if(empty($auth)) {
$mszAuth = (string)$request->getCookie('msz_auth');
if(!empty($mszAuth))
$auth = 'Misuzu ' . $mszAuth;
}
if(!empty($auth)) {
$authParts = explode(' ', $auth, 2);
$authMethod = strval($authParts[0] ?? '');

View file

@ -59,8 +59,9 @@ EEPROM.EEPROMFile = function(fileInfo) {
};
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.isMedia = function() { return obj.isImage() || obj.isAudio() || obj.isVideo(); };
return obj;
};
@ -109,7 +110,8 @@ EEPROM.EEPROMDeleteTask = function(authorization, fileInfo) {
obj.start = function() {
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();
};
@ -202,7 +204,8 @@ EEPROM.EEPROMUploadTask = function(srcId, endpoint, authorization, file) {
obj.start = function() {
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);
};