Login redirect 307 (temporary)

This commit is contained in:
Juan Pablo Vial
2024-04-03 13:26:12 -03:00
parent 8710c8a111
commit 905e8263bc
4 changed files with 4 additions and 22 deletions

View File

@ -2,13 +2,6 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.9.3/semantic.min.js" integrity="sha512-gnoBksrDbaMnlE0rhhkcx3iwzvgBGz6mOEj4/Y5ZY09n55dYddx6+WYc72A55qEesV8VX2iMomteIwobeGK1BQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script type="text/javascript">
function cleanNoCache() {
const url = new URL(window.location.href)
if (url.searchParams.has('nocache')) {
url.searchParams.delete('nocache')
window.location.href = url.href
}
}
function fetchAPI(url, options=null) {
if (options === null) {
options = {}
@ -17,11 +10,7 @@
options['headers'] = {}
}
if (!Object.hasOwn(options['headers'], 'Authorization')) {
@if (!$login->isIn())
options['headers']['Authorization'] = 'Bearer {{md5($API_KEY)}}'
@else
options['headers']['Authorization'] = 'Bearer {{md5($API_KEY)}}{{$login->getSeparator()}}{{$login->getToken()}}'
@endif
options['headers']['Authorization'] = 'Bearer {{md5($API_KEY)}}{{($login->isIn()) ? $login->getSeparator() . $login->getToken() : ''}}'
}
return fetch(url, options).then(response => {
if (response.ok) {
@ -47,9 +36,6 @@
date: 'DD-MM-YYYY'
},
}
/*$(document).ready(() => {
cleanNoCache()
})*/
</script>
@stack('page_scripts')

View File

@ -39,11 +39,7 @@
}
}).then(data => {
if (data.login === true) {
@if(isset($redirect_uri))
window.location = '{{$redirect_uri}}?nocache=' + (new Date()).getTime()
@else
window.location = '{{$urls->base}}?nocache=' + (new Date()).getTime()
@endif
window.location = '{{(isset($redirect_uri)) ? $redirect_uri : $urls->base}}'
}
})
}

View File

@ -24,7 +24,7 @@ class Authentication
return $handler->handle($request);
}
$this->logger->notice("Not logged in.");
$response = $this->responseFactory->createResponse(301, 'Not logged in')
$response = $this->responseFactory->createResponse(307, 'Not logged in')
->withHeader('Referer', (string) $request->getUri())
->withHeader('X-Redirected-URI', (string) $request->getUri());
$url = "{$request->getUri()}";

View File

@ -22,7 +22,7 @@ class Errors
} catch (Error $error) {
$this->logger->error($error);
}
$response = $this->responseFactory->createResponse(600, 'Internal Server Error');
$response = $this->responseFactory->createResponse(500, 'Internal Server Error');
if (str_contains($request->getUri()->getPath(), '/api')) {
return $response;
}