Compare commits
No commits in common. "af987ce195a8380721534bbd3218194cd2d68f3c" and "82e1d078f588ded5205875646e1597efc0b4dba8" have entirely different histories.
af987ce195
...
82e1d078f5
@ -9,25 +9,18 @@ const authModes = [
|
|||||||
"password",
|
"password",
|
||||||
];
|
];
|
||||||
|
|
||||||
function getBase64fromPath (pathstring) {
|
function getBGMain () {
|
||||||
if (typeof pathstring === "string" && pathstring !== "") {
|
let bgMain = global.config.source.bgmain;
|
||||||
if (!path.isAbsolute(pathstring))
|
if (typeof bgMain === "string") {
|
||||||
pathstring = path.join(__dirname, "..", pathstring);
|
if (!path.isAbsolute(bgMain))
|
||||||
const mimetype = mime.lookup(pathstring);
|
bgMain = path.join(__dirname, "..", bgMain);
|
||||||
const base64content = fs.readFileSync(pathstring, { encoding: 'base64' });
|
const mimetype = mime.lookup(bgMain);
|
||||||
|
const base64content = fs.readFileSync(bgMain, { encoding: 'base64' });
|
||||||
return `data:${mimetype};base64,${base64content}`;
|
return `data:${mimetype};base64,${base64content}`;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBGMain () {
|
|
||||||
return getBase64fromPath(global.config.source.bgmain);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getFaviconMain () {
|
|
||||||
return getBase64fromPath(global.config.source.favicon);
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: global.config.server.info.name,
|
name: global.config.server.info.name,
|
||||||
tag: global.config.server.info.tag,
|
tag: global.config.server.info.tag,
|
||||||
@ -35,6 +28,5 @@ module.exports = {
|
|||||||
secureMode: global.config.server.secureMode ?? false,
|
secureMode: global.config.server.secureMode ?? false,
|
||||||
extSource: {
|
extSource: {
|
||||||
bgmain: getBGMain(),
|
bgmain: getBGMain(),
|
||||||
favicon: getFaviconMain(),
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -20,5 +20,5 @@ module.exports = async function (con, req, cb) {
|
|||||||
const user = User.getByToken(req.token);
|
const user = User.getByToken(req.token);
|
||||||
if (user === null) return invalidData();
|
if (user === null) return invalidData();
|
||||||
global.authed.set(con, user);
|
global.authed.set(con, user);
|
||||||
return ok(user.getUserForAPI(true));
|
ok(user.getUserForAPI(true));
|
||||||
};
|
};
|
||||||
|
@ -24,8 +24,7 @@
|
|||||||
"apiType": "kobold"
|
"apiType": "kobold"
|
||||||
},
|
},
|
||||||
"source": {
|
"source": {
|
||||||
"bgmain": "/home/fullgream/Downloads/21380429c504a974479d31c96a9c3c3f.jpg",
|
"bgmain": "/home/fullgream/Загрузки/21380429c504a974479d31c96a9c3c3f.jpg"
|
||||||
"favicon": "/home/fullgream/Documents/website-server/root/website-core/static/favicon.png"
|
|
||||||
},
|
},
|
||||||
"rootuser": {
|
"rootuser": {
|
||||||
"login": "admin",
|
"login": "admin",
|
||||||
|
@ -111,19 +111,6 @@
|
|||||||
padding: 5px;
|
padding: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mainmenu-window {
|
|
||||||
background-color: rgba(33,37,41,0.75);
|
|
||||||
backdrop-filter: blur(5px);
|
|
||||||
border-radius : 15px;
|
|
||||||
width: calc(90vw);
|
|
||||||
height: calc(80vh);
|
|
||||||
|
|
||||||
margin-left: calc(5%);
|
|
||||||
margin-top: calc(5%);
|
|
||||||
|
|
||||||
padding: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* $accordion-color:green; */
|
/* $accordion-color:green; */
|
||||||
/* $accordion-padding-y:1.3rem; */
|
/* $accordion-padding-y:1.3rem; */
|
||||||
/* $accordion-padding-x:2.5rem; */
|
/* $accordion-padding-x:2.5rem; */
|
||||||
|
@ -88,29 +88,25 @@ class ApiHTML {
|
|||||||
this.api = api;
|
this.api = api;
|
||||||
}
|
}
|
||||||
|
|
||||||
async renderMainMenu (user, bgUrl = null, favicon = null) {
|
async renderMainMenu (user, bgUrl = null) {
|
||||||
bgUrl = bgUrl ?? "assets/hello/1.png";
|
bgUrl = bgUrl ?? "assets/hello/1.png";
|
||||||
favicon = favicon ?? "favicon.png";
|
|
||||||
|
|
||||||
document.body.style.backgroundImage = `url(${
|
document.body.style.backgroundImage = `url(${
|
||||||
JSON.stringify(bgUrl)
|
JSON.stringify(bgUrl)
|
||||||
})`;
|
})`;
|
||||||
document.body.style.backgroundSize = `${screen.width}px ${screen.height}px`;
|
document.body.style.backgroundSize = `${screen.width}px ${screen.height}px`;
|
||||||
$.find('link[rel="icon"]')[0].href = favicon;
|
|
||||||
|
|
||||||
document.getElementById("server.area").innerHTML = '';
|
document.getElementById("server.area").innerHTML = '';
|
||||||
$(document.getElementById("server.area")).append(ServerAuth.mainMenuForm);
|
//$(document.getElementById("server.area")).append(ServerAuth.authForm);
|
||||||
}
|
}
|
||||||
|
|
||||||
async renderAuth (authMode, bgUrl = null, favicon = null) {
|
async renderAuth (authMode, bgUrl = null) {
|
||||||
bgUrl = bgUrl ?? "assets/hello/1.png";
|
bgUrl = bgUrl ?? "assets/hello/1.png";
|
||||||
favicon = favicon ?? "favicon.png";
|
|
||||||
|
|
||||||
document.body.style.backgroundImage = `url(${
|
document.body.style.backgroundImage = `url(${
|
||||||
JSON.stringify(bgUrl)
|
JSON.stringify(bgUrl)
|
||||||
})`;
|
})`;
|
||||||
document.body.style.backgroundSize = `${screen.width}px ${screen.height}px`;
|
document.body.style.backgroundSize = `${screen.width}px ${screen.height}px`;
|
||||||
$.find('link[rel="icon"]')[0].href = favicon;
|
|
||||||
|
|
||||||
document.getElementById("server.area").innerHTML = '';
|
document.getElementById("server.area").innerHTML = '';
|
||||||
$(document.getElementById("server.area")).append(ServerAuth.authForm);
|
$(document.getElementById("server.area")).append(ServerAuth.authForm);
|
||||||
@ -147,7 +143,7 @@ class ApiHTML {
|
|||||||
.then(user => {
|
.then(user => {
|
||||||
const { token } = user;
|
const { token } = user;
|
||||||
localStorage.setItem(`my-token>${!isTLSmode ? "ws" : "wss"}://${address}:${port}`, token);
|
localStorage.setItem(`my-token>${!isTLSmode ? "ws" : "wss"}://${address}:${port}`, token);
|
||||||
this.renderMainMenu(user, bgUrl, favicon);
|
this.renderMainMenu(user, bgUrl);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
$.find("#reg-btn")[0].onclick = () => { }
|
$.find("#reg-btn")[0].onclick = () => { }
|
||||||
|
@ -91,21 +91,3 @@ ServerAuth.authForm.innerHTML = `
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
// Main menu form
|
// Main menu form
|
||||||
ServerAuth.mainMenuForm = document.createElement("div");
|
|
||||||
["mainmenu-window"].forEach(c =>
|
|
||||||
ServerAuth.mainMenuForm.classList.add(c));
|
|
||||||
ServerAuth.mainMenuForm.innerHTML = `
|
|
||||||
<div id="games-panel" hidden>
|
|
||||||
<div id="games-content">
|
|
||||||
<center><h2>Games</h2></center><hr/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="main-panel" >
|
|
||||||
<div id="main-content">
|
|
||||||
<center><h2>Your Profile</h2></center><hr/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="mainmenu-load" hidden><center>Loading...</center></div>
|
|
||||||
`;
|
|
||||||
|
@ -68,9 +68,9 @@ socket.run()
|
|||||||
const isAuthed = await socket.methods.authed();
|
const isAuthed = await socket.methods.authed();
|
||||||
|
|
||||||
if (!user || !isAuthed)
|
if (!user || !isAuthed)
|
||||||
await socket.html.renderAuth(data.authMode, data.extSource?.bgmain ?? null, data.extSource?.favicon ?? null);
|
await socket.html.renderAuth(data.authMode, data.extSource?.bgmain ?? null);
|
||||||
else
|
else
|
||||||
await socket.html.renderMainMenu(user, data.extSource?.bgmain ?? null, data.extSource?.favicon ?? null);
|
await socket.html.renderMainMenu(user, data.extSource?.bgmain ?? null);
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
Loading…
Reference in New Issue
Block a user