fix token validation + error notif

This commit is contained in:
Smith
2022-07-21 10:03:05 +02:00
parent 5266e5854f
commit f9190cf6bd
3 changed files with 4 additions and 7 deletions

3
dist/server.js vendored
View File

@@ -143,8 +143,7 @@ function validateBearerToken(btoken) {
if (salt.length > 24
&& /^\d{13}$/.test(valid)
&& /^[a-f0-9]{128}$/.test(hash)
&& Date.now() < Number(valid)
&& Number(valid) - Date.now() < 3600000 * 12) {
&& Date.now() < Number(valid)) {
return hash === crypto_1.default.createHash('sha512').update(salt + valid + SECRET).digest('hex');
}
return false;

View File

@@ -486,7 +486,7 @@ async function fetchApi(method, endpoint, body) {
if (!re) {
logout();
notif('danger', '⚠️ ' + errMsg, 3);
notif('danger', '⚠️ ' + errMsg, undefined, undefined, 3);
}
return re;
@@ -501,8 +501,7 @@ async function getBearerToken() {
if (salt.length > 24
&& /^\d{13}$/.test(valid)
&& /^[0-9a-f]{128}$/.test(hash)
&& Date.now() < Number(valid)
&& Number(valid) - Date.now() < 3600000 * 12) {
&& Date.now() < Number(valid)) {
return bt;
}
}

View File

@@ -148,8 +148,7 @@ function validateBearerToken(btoken: string) {
if (salt.length > 24
&& /^\d{13}$/.test(valid)
&& /^[a-f0-9]{128}$/.test(hash)
&& Date.now() < Number(valid)
&& Number(valid) - Date.now() < 3600000 * 12) {
&& Date.now() < Number(valid)) {
return hash === crypto.createHash('sha512').update(salt + valid + SECRET).digest('hex');
}