fix auth
This commit is contained in:
parent
c603bc8755
commit
9c2deb3dcb
2 changed files with 24 additions and 22 deletions
44
game.js
44
game.js
|
@ -20,7 +20,7 @@ class Game extends GameBasic {
|
||||||
}
|
}
|
||||||
async updateLeaderboard() {
|
async updateLeaderboard() {
|
||||||
let jason = await db.all('SELECT * FROM stats ORDER BY CAST(ko AS REAL) DESC LIMIT 1000');
|
let jason = await db.all('SELECT * FROM stats ORDER BY CAST(ko AS REAL) DESC LIMIT 1000');
|
||||||
|
|
||||||
let scoresOld = this.scores || [];
|
let scoresOld = this.scores || [];
|
||||||
|
|
||||||
let scores = {};
|
let scores = {};
|
||||||
|
@ -38,7 +38,7 @@ class Game extends GameBasic {
|
||||||
let s = Object.entries(scores).sort((a, b) => b[1] - a[1]).filter(a => a[1] > 5);
|
let s = Object.entries(scores).sort((a, b) => b[1] - a[1]).filter(a => a[1] > 5);
|
||||||
|
|
||||||
for (let x in s) {
|
for (let x in s) {
|
||||||
let jk = jason.filter(y => y.ip == s[x][0]).map(y => y.ko).sort((a,b) => b - a);
|
let jk = jason.filter(y => y.ip == s[x][0]).map(y => y.ko).sort((a, b) => b - a);
|
||||||
|
|
||||||
s[x].push(jk.join(', '));
|
s[x].push(jk.join(', '));
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ class Game extends GameBasic {
|
||||||
this.scores = s;
|
this.scores = s;
|
||||||
|
|
||||||
s = [...s];
|
s = [...s];
|
||||||
s.length = Math.min(s.length,10);
|
s.length = Math.min(s.length, 10);
|
||||||
|
|
||||||
let message = [];
|
let message = [];
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ class Game extends GameBasic {
|
||||||
basic[posn] = sround(posp);
|
basic[posn] = sround(posp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let str = JSON.stringify(basic,null);
|
let str = JSON.stringify(basic, null);
|
||||||
|
|
||||||
entList.push({ entity, str, basic });
|
entList.push({ entity, str, basic });
|
||||||
}
|
}
|
||||||
|
@ -221,31 +221,33 @@ class Game extends GameBasic {
|
||||||
async authUser(ws, data) {
|
async authUser(ws, data) {
|
||||||
ws.token = data;
|
ws.token = data;
|
||||||
|
|
||||||
let f = new FormData();
|
let j = false;
|
||||||
f.append('token', ws.token);
|
|
||||||
|
|
||||||
let j = await fetch("https://bg.dervland.net/api/form/auth_api/",
|
|
||||||
{
|
|
||||||
"method": "post",
|
|
||||||
"body": f
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
j = await j.text();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
j = JSON.parse(j);
|
j = await fetch("https://nbg.dervland.net/auth.php",
|
||||||
|
{
|
||||||
|
"method": "get",
|
||||||
|
"headers": {
|
||||||
|
"cookie": `token=${data}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
j = await j.text();
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
j = {};
|
j = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (j.username == '!nobody' || !j.username) return;
|
j = j.replaceAll(/\s+/g,'');
|
||||||
|
|
||||||
if (this.ws.findIndex(x => x.username == j.username && x.ent.health > 0) != -1) {
|
if (!j || j == '') return;
|
||||||
console.log(`Player ${ws.ent.you} uses username ${j.username} illegally`)
|
|
||||||
|
if (this.ws.findIndex(x => x.username == j && x.ent.health > 0) != -1) {
|
||||||
|
console.log(`Player ${ws.ent.you} uses username ${j} illegally`)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ws.ent.username = ws.username = j.username;
|
ws.ent.username = ws.username = j;
|
||||||
|
|
||||||
console.log(`Player ${ws.ent.you} uses username ${ws.username}`)
|
console.log(`Player ${ws.ent.you} uses username ${ws.username}`)
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<p>The <b>left mouse button</b> is the only input. No keyboard, moving the mouse, or anything else.</p>
|
<p>The <b>left mouse button</b> is the only input. No keyboard, moving the mouse, or anything else.</p>
|
||||||
<p>Click to launch... figure out the rest of the combos yourself.</p>
|
<p>Click to launch... figure out the rest of the combos yourself.</p>
|
||||||
<a class='button' href='https://dervland.net/'>Created by 08draven</a>
|
<a class='button' href='https://dervland.net/'>Created by 08draven</a>
|
||||||
<a class='button' href='https://bg.dervland.net/client/login?redirect=https://ub.dervland.net/'>Log in</a>
|
<a class='button' href='https://nbg.dervland.net/login.php?next=https://ub.dervland.net/'>Log in</a>
|
||||||
<canvas id='canvas'></canvas>
|
<canvas id='canvas'></canvas>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
Loading…
Reference in a new issue