Compare commits
12 Commits
550fa0fbe4
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 19bb1942d8 | |||
| 11bf2e6807 | |||
| 65530963d7 | |||
| cccaf58ec3 | |||
| 020a2ae815 | |||
| f393496a1b | |||
| a805cb77fc | |||
| c282c6b597 | |||
| c420f643b7 | |||
| 8a4f98c5fd | |||
| ac17b5906e | |||
| 46c475593b |
@@ -2,8 +2,13 @@ FROM node:22-bullseye
|
||||
|
||||
WORKDIR /opt/mcserver
|
||||
|
||||
COPY . .
|
||||
COPY package.json package.json
|
||||
COPY package-lock.json package-lock.json
|
||||
|
||||
RUN npm i
|
||||
|
||||
COPY . .
|
||||
|
||||
EXPOSE 3000
|
||||
ENTRYPOINT ["node", "./src/index.js"]
|
||||
ENTRYPOINT ["node", "./src/index.js"]
|
||||
|
||||
|
||||
@@ -64,6 +64,7 @@ canvas {
|
||||
margin-top: 0%;
|
||||
border: solid 2px gray;
|
||||
box-shadow: 0px 20px 150px rgba(0, 0, 0, 1);
|
||||
height:100%;
|
||||
}
|
||||
|
||||
.action-tabs {
|
||||
@@ -133,4 +134,9 @@ canvas {
|
||||
margin-bottom: 8px;
|
||||
margin-left: 8px;
|
||||
margin-right: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
.map-container {
|
||||
width: 100%;
|
||||
height: 90%;
|
||||
}
|
||||
|
||||
@@ -44,9 +44,6 @@ $(document).ready(async () => {
|
||||
|
||||
await onFetchMessageButtonClick();
|
||||
|
||||
|
||||
|
||||
|
||||
socket.onmessage = message => {
|
||||
try {
|
||||
message = JSON.parse(message.data)
|
||||
|
||||
@@ -10,12 +10,16 @@ const uploadSkin = async (event) => {
|
||||
let formData = new FormData();
|
||||
formData.append("file", skinFile);
|
||||
|
||||
await fetch(`/api/uploadSkin`, {
|
||||
const response = await fetch(`/api/uploadSkin`, {
|
||||
method: "POST",
|
||||
body: formData
|
||||
})
|
||||
|
||||
window.location = window.location.href+'?eraseCache=true';
|
||||
if (response.status != 200) {
|
||||
alert(await response.text())
|
||||
} else {
|
||||
window.location.reload(true);
|
||||
}
|
||||
}
|
||||
|
||||
const uploadCape = async (event) => {
|
||||
@@ -30,15 +34,18 @@ const uploadCape = async (event) => {
|
||||
let formData = new FormData();
|
||||
formData.append("file", capeFile);
|
||||
|
||||
await fetch(`/api/uploadCape`, {
|
||||
const response = await fetch(`/api/uploadCape`, {
|
||||
method: "POST",
|
||||
body: formData
|
||||
})
|
||||
|
||||
window.location = window.location.href+'?eraseCache=true';
|
||||
if (response.status != 200) {
|
||||
alert(await response.text())
|
||||
} else {
|
||||
window.location.reload(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
window.onload = async function() {
|
||||
document.getElementById("skinForm").addEventListener("submit", uploadSkin)
|
||||
if (document.getElementById("cape")) {
|
||||
@@ -52,16 +59,19 @@ window.onload = async function() {
|
||||
document.getElementById("elytra").checked = false;
|
||||
}
|
||||
|
||||
const username = await (await (fetch("/api/getUsername"))).text();
|
||||
const username = await (await (fetch('/api/getUsername'))).text();
|
||||
const skinsUrl = (await (await fetch('/api/skinsUrl')).text()).replace('%username%', username);
|
||||
const capesUrl = (await (await fetch('/api/capesUrl')).text()).replace('%username%', username);
|
||||
|
||||
let skinViewer = new skinview3d.SkinViewer({
|
||||
canvas: document.getElementById("skin_container"),
|
||||
width: 300,
|
||||
height: 400,
|
||||
skin: `https://launcher.foxarmy.org/skins/${username}.png`,
|
||||
cape: `https://launcher.foxarmy.org/cloaks/${username}.png`
|
||||
skin: skinsUrl,
|
||||
cape: capesUrl
|
||||
});
|
||||
|
||||
|
||||
skinViewer.nameTag = username;
|
||||
skinViewer.loadPanorama("images/panorama.jpeg");
|
||||
skinViewer.fov = 120;
|
||||
@@ -69,7 +79,7 @@ window.onload = async function() {
|
||||
skinViewer.autoRotate = true;
|
||||
|
||||
function set_cape_type(type) {
|
||||
skinViewer.loadCape(`https://launcher.foxarmy.org/cloaks/${username}.png`, { backEquipment: type });
|
||||
skinViewer.loadCape(capesUrl, { backEquipment: type });
|
||||
}
|
||||
|
||||
|
||||
|
||||
32
sample.env
32
sample.env
@@ -1,10 +1,30 @@
|
||||
SECRET=GENERATE_A_STRONG_SECRET_HERE
|
||||
#Databse
|
||||
DBUSER=mcserver
|
||||
DBHOST=localhost
|
||||
DBHOST=database
|
||||
DBNAME=mcserver
|
||||
DBPORT=5432
|
||||
DBPORT=5433
|
||||
DBPASS=GENERATE_A_STRONG_PASSWORD_HERE
|
||||
PORT=3000
|
||||
REQUIRE_TOKEN=false
|
||||
|
||||
#General
|
||||
SECRET=GENERATE_A_STRONG_SECRET_HERE
|
||||
APP_PORT=3000
|
||||
|
||||
#Token
|
||||
REQUIRE_TOKEN=true
|
||||
DELETE_TOKEN_ON_USE=true
|
||||
WS_CONNECTION_STRING=wss://auth.foxarmy.org
|
||||
|
||||
#Chat
|
||||
ENABLE_CHAT=false
|
||||
WS_CONNECTION_STRING=ws://localhost:3000
|
||||
|
||||
#Map
|
||||
ENABLE_WORLDMAP=false
|
||||
WORLDMAP_URL=http://localhost/map
|
||||
|
||||
#Skins
|
||||
SKINS_TARGET_DIRECTORY=/opt/skins
|
||||
SKINS_URL=https://launcher.foxarmy.org/skins/%username%.png
|
||||
|
||||
#Capes
|
||||
CAPES_TARGET_DIRECTORY=/opt/cloaks
|
||||
CAPES_URL=https://launcher.foxarmy.org/cloaks/%username%.png
|
||||
33
src/config.js
Normal file
33
src/config.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import dotenv from 'dotenv';
|
||||
|
||||
dotenv.config({ path: ".env" });
|
||||
|
||||
const getBoolean = value => { return value === 'true'? true : false }
|
||||
|
||||
const config = {
|
||||
dbuser: process.env.DBUSER,
|
||||
dbhost: process.env.DBHOST,
|
||||
dbname: process.env.DBNAME,
|
||||
dbport: Number.parseInt(process.env.DBPORT),
|
||||
dbpass: process.env.DBPASS,
|
||||
|
||||
secret: process.env.SECRET,
|
||||
app_port: Number.parseInt(process.env.APP_PORT),
|
||||
|
||||
require_token: getBoolean(process.env.REQUIRE_TOKEN),
|
||||
delete_token_on_use: getBoolean(process.env.DELETE_TOKEN_ON_USE),
|
||||
|
||||
enable_chat: getBoolean(process.env.ENABLE_CHAT),
|
||||
ws_connection_string: process.env.WS_CONNECTION_STRING,
|
||||
|
||||
enable_worldmap: getBoolean(process.env.ENABLE_WORLDMAP),
|
||||
worldmap_url: process.env.WORLDMAP_URL,
|
||||
|
||||
skins_target_directory: process.env.SKINS_TARGET_DIRECTORY,
|
||||
skins_url: process.env.SKINS_URL,
|
||||
|
||||
capes_target_directory: process.env.CAPES_TARGET_DIRECTORY,
|
||||
capes_url: process.env.CAPES_URL
|
||||
}
|
||||
|
||||
export default config;
|
||||
@@ -1,7 +1,5 @@
|
||||
import ApiService from "../services/api.js";
|
||||
import dotenv from 'dotenv';
|
||||
|
||||
dotenv.config({path: ".env"});
|
||||
import config from '../config.js';
|
||||
|
||||
class ApiController {
|
||||
async getChatMessages(req, res) {
|
||||
@@ -13,7 +11,15 @@ class ApiController {
|
||||
}
|
||||
|
||||
async getWebsocketConnection(req, res) {
|
||||
return res.status(200).send(process.env.WS_CONNECTION_STRING)
|
||||
return res.status(200).send(config.ws_connection_string);
|
||||
}
|
||||
|
||||
async getSkinsUrl(req, res) {
|
||||
return res.status(200).send(config.skins_url);
|
||||
}
|
||||
|
||||
async getCapesUrl(req, res) {
|
||||
return res.status(200).send(config.capes_url);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import bcrypt from 'bcrypt';
|
||||
import jwt from 'jsonwebtoken';
|
||||
import dotenv from 'dotenv';
|
||||
import path from 'path';
|
||||
import { Jimp } from 'jimp';
|
||||
import fs from 'fs';
|
||||
|
||||
import UserService from "../services/user.js";
|
||||
import utils from '../utils.js';
|
||||
import config from '../config.js';
|
||||
|
||||
dotenv.config({path: ".env"});
|
||||
class UserController {
|
||||
async register(req, res) {
|
||||
const { username, password } = req.body;
|
||||
@@ -27,24 +26,24 @@ class UserController {
|
||||
|
||||
await UserService.register(username, hashedPassword);
|
||||
|
||||
if (process.env.REQUIRE_TOKEN == "true" && process.env.DELETE_TOKEN_ON_USE == "true") {
|
||||
if (config.require_token && config.delete_token_on_use) {
|
||||
utils.removeFromFile('./inviteTokens.txt', req.body.inviteToken);
|
||||
}
|
||||
|
||||
const token = jwt.sign({ username }, process.env.SECRET, {expiresIn: "1y"});
|
||||
const token = jwt.sign({ username }, config.secret, { expiresIn: "1y" });
|
||||
res.cookie("jwt", token);
|
||||
return res.status(200).send("Ok");
|
||||
}
|
||||
|
||||
async login(req, res) {
|
||||
const {username, password} = req.body;
|
||||
const { username, password } = req.body;
|
||||
|
||||
const storedPassword = await UserService.getPassword(username);
|
||||
|
||||
if (!bcrypt.compareSync(password, storedPassword)) {
|
||||
return res.status(403).send("Password is not correct");
|
||||
}
|
||||
const token = jwt.sign({ username }, process.env.SECRET, {expiresIn: "1y"});
|
||||
const token = jwt.sign({ username }, config.secret, { expiresIn: "1y" });
|
||||
res.cookie("jwt", token);
|
||||
return res.status(200).send("Ok");
|
||||
}
|
||||
@@ -77,21 +76,28 @@ class UserController {
|
||||
const token = req.cookies["jwt"];
|
||||
const decoded = jwt.decode(token);
|
||||
const tempPath = req.file.path;
|
||||
const targetPath = `/opt/skins/${decoded.username}.png`;
|
||||
const targetPath = config.skins_target_directory + `/${decoded.username}.png`;
|
||||
|
||||
if (path.extname(req.file.originalname).toLowerCase() !== ".png") {
|
||||
return res.status(400).send("Only .png files are allowed!");
|
||||
}
|
||||
|
||||
|
||||
const image = await Jimp.read(tempPath);
|
||||
if (image.bitmap.width != 64 || image.bitmap.height != 64) {
|
||||
try {
|
||||
const image = await Jimp.read(tempPath);
|
||||
} catch (err) {
|
||||
console.log(`Error during cape installation, ${err}`)
|
||||
return res.status(500).send("Internal server error. Please, report to the developer.")
|
||||
}
|
||||
const allowedWidths = [32, 64, 128];
|
||||
const allowedHeights = [32, 64];
|
||||
if (!allowedWidths.includes(image.bitmap.width) || !allowedHeights.includes(image.bitmap.height)) {
|
||||
return res.status(400).send('This does not look like a minecraft skin.');
|
||||
}
|
||||
|
||||
fs.renameSync(tempPath, targetPath, err => {
|
||||
if (err) return res.status(500).send("Ooops! Something went wrong! Please, report to the developer.");
|
||||
});
|
||||
try {
|
||||
await fs.promises.cp(tempPath, targetPath);
|
||||
await fs.promises.unlink(tempPath);
|
||||
} catch (err) {
|
||||
return res.status(500).send("Ooops! Something went wrong! Please, report to the developer.");
|
||||
}
|
||||
return res.status(200).send("Skin uploaded!");
|
||||
}
|
||||
|
||||
@@ -99,21 +105,28 @@ class UserController {
|
||||
const token = req.cookies["jwt"];
|
||||
const decoded = jwt.decode(token);
|
||||
const tempPath = req.file.path;
|
||||
const targetPath = `/opt/cloaks/${decoded.username}.png`;
|
||||
const targetPath = config.capes_target_directory + `/${decoded.username}.png`;
|
||||
|
||||
if (path.extname(req.file.originalname).toLowerCase() !== ".png") {
|
||||
return res.status(400).send("Only .png files are allowed!");
|
||||
}
|
||||
|
||||
|
||||
const image = await Jimp.read(tempPath);
|
||||
try {
|
||||
const image = await Jimp.read(tempPath);
|
||||
}
|
||||
catch (err) {
|
||||
console.log(`Error during cape installation, ${err}`)
|
||||
return res.status(500).send("Internal server error. Please, report to the developer.")
|
||||
}
|
||||
if ((image.bitmap.width != 64 || image.bitmap.height != 32) && (image.bitmap.width != 128 || image.bitmap.height != 64)) {
|
||||
return res.status(400).send('This does not look like a minecraft cape.');
|
||||
}
|
||||
|
||||
fs.renameSync(tempPath, targetPath, err => {
|
||||
if (err) return res.status(500).send("Ooops! Something went wrong! Please, report to the developer.");
|
||||
});
|
||||
try {
|
||||
await fs.promises.cp(tempPath, targetPath);
|
||||
await fs.promises.unlink(tempPath);
|
||||
} catch (err) {
|
||||
return res.status(500).send("Ooops! Something went wrong! Please, report to the developer.");
|
||||
}
|
||||
|
||||
return res.status(200).send("Cape uploaded!");
|
||||
}
|
||||
@@ -124,4 +137,4 @@ class UserController {
|
||||
}
|
||||
}
|
||||
|
||||
export default new UserController();
|
||||
export default new UserController();
|
||||
|
||||
13
src/db.js
13
src/db.js
@@ -1,19 +1,18 @@
|
||||
import pg from 'pg';
|
||||
import fs from 'fs';
|
||||
import dotenv from 'dotenv';
|
||||
|
||||
dotenv.config({path: ".env"});
|
||||
import config from './config.js';
|
||||
|
||||
const { Pool } = pg;
|
||||
|
||||
console.log("Connecting to PostgreSQL database");
|
||||
|
||||
const pool = new Pool({
|
||||
user: process.env.DBUSER,
|
||||
host: process.env.DBHOST,
|
||||
database: process.env.DBNAME,
|
||||
password: process.env.DBPASS,
|
||||
port: process.env.DBPORT
|
||||
user: config.dbuser,
|
||||
host: config.dbhost,
|
||||
database: config.dbnape,
|
||||
password: config.dbpass,
|
||||
port: config.dbport
|
||||
});
|
||||
|
||||
pool.query(fs.readFileSync('./db_schema.psql').toString());
|
||||
|
||||
13
src/index.js
13
src/index.js
@@ -1,5 +1,4 @@
|
||||
import express from 'express';
|
||||
import dotenv from 'dotenv';
|
||||
import session from 'express-session';
|
||||
import cookieParser from 'cookie-parser';
|
||||
import path from 'path';
|
||||
@@ -7,13 +6,12 @@ import path from 'path';
|
||||
import ApiRouter from './routers/api.js';
|
||||
import UserRouter from './routers/user.js';
|
||||
import startChat from './messages.js';
|
||||
import config from './config.js';
|
||||
|
||||
const app = express();
|
||||
|
||||
dotenv.config({ path: ".env" });
|
||||
|
||||
app.use(session({
|
||||
secret: process.env.SECRET,
|
||||
secret: config.secret,
|
||||
resave: true,
|
||||
saveUninitialized: false,
|
||||
cookie: { maxAge: 1000 * 60 * 60 * 24 }
|
||||
@@ -28,9 +26,12 @@ app.set('view engine', 'pug');
|
||||
app.use('/api', ApiRouter);
|
||||
app.use('/', UserRouter);
|
||||
|
||||
const server = app.listen(process.env.PORT, () => {
|
||||
const server = app.listen(config.app_port, () => {
|
||||
console.log("App has been started!");
|
||||
startChat();
|
||||
|
||||
if(config.enable_chat) {
|
||||
startChat();
|
||||
}
|
||||
});
|
||||
|
||||
export default server;
|
||||
|
||||
@@ -112,4 +112,4 @@ const startChat = async () => {
|
||||
})
|
||||
}
|
||||
|
||||
export default startChat;
|
||||
export default startChat;
|
||||
|
||||
@@ -1,23 +1,29 @@
|
||||
import fs from 'fs';
|
||||
import dotenv from 'dotenv';
|
||||
import jwt from 'jsonwebtoken';
|
||||
|
||||
import UserService from '../services/user.js';
|
||||
import config from '../config.js';
|
||||
|
||||
dotenv.config({path: ".env"});
|
||||
|
||||
const authenticate = async (req, res, next) => {
|
||||
const token = req.cookies["jwt"];
|
||||
if (!token || !jwt.verify(token, process.env.SECRET)) {
|
||||
req.session.destroy();
|
||||
try {
|
||||
const token = req.cookies["jwt"];
|
||||
if (!token || !jwt.verify(token, config.secret)) {
|
||||
req.session.destroy();
|
||||
res.clearCookie("jwt");
|
||||
return res.redirect("/login");
|
||||
}
|
||||
next();
|
||||
} catch(e) {
|
||||
console.log(e)
|
||||
req.session.destroy();
|
||||
res.clearCookie("jwt");
|
||||
return res.redirect("/login");
|
||||
}
|
||||
next();
|
||||
};
|
||||
|
||||
const validateInviteToken = async (req, res, next) => {
|
||||
if (process.env.REQUIRE_TOKEN != "true") return next();
|
||||
if (!config.require_token) return next();
|
||||
|
||||
const { inviteToken } = req.body;
|
||||
if (!inviteToken || inviteToken == "") return res.status(400).send("Token is not valid");
|
||||
@@ -40,4 +46,4 @@ const canHaveCloak = async (req, res, next) => {
|
||||
next();
|
||||
}
|
||||
|
||||
export default {authenticate, validateInviteToken, canHaveCloak};
|
||||
export default {authenticate, validateInviteToken, canHaveCloak};
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import dotenv from 'dotenv';
|
||||
import jwt from 'jsonwebtoken';
|
||||
|
||||
import UserService from '../services/user.js';
|
||||
|
||||
dotenv.config({path: ".env"});
|
||||
import config from '../config.js';
|
||||
|
||||
const userDoesNotExist = async (req, res, next) => {
|
||||
|
||||
@@ -20,7 +18,7 @@ const userExist = async (req, res, next) => {
|
||||
if (req.body.username) {
|
||||
username = req.body.username;
|
||||
} else if (req.cookies["jwt"]) {
|
||||
if (!req.cookies["jwt"] || !jwt.verify(req.cookies["jwt"], process.env.SECRET)) {
|
||||
if (!req.cookies["jwt"] || !jwt.verify(req.cookies["jwt"], config.secret)) {
|
||||
return res.status(403).send("Unauthorized");
|
||||
}
|
||||
username = jwt.decode(req.cookies["jwt"]).username;
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import dotenv from 'dotenv';
|
||||
|
||||
dotenv.config({path: ".env"});
|
||||
import config from '../config.js';
|
||||
|
||||
const requireUsername = async (req, res, next) => {
|
||||
const { username } = req.body;
|
||||
@@ -19,7 +17,7 @@ const requirePassword = async (req, res, next) => {
|
||||
const requireInviteToken = async (req, res, next) => {
|
||||
const { inviteToken } = req.body;
|
||||
|
||||
if (!inviteToken && process.env.REQUIRE_TOKEN == "true") return res.status(400).send("Invite token is required");
|
||||
if (!inviteToken && config.require_token) return res.status(400).send("Invite token is required");
|
||||
next();
|
||||
};
|
||||
|
||||
|
||||
@@ -14,10 +14,15 @@ ApiRouter.post('/register', requiredParameters.requireUsername, requiredParamete
|
||||
ApiRouter.post('/login', requiredParameters.requireUsername, requiredParameters.requirePassword, existance.userExist, UserController.login);
|
||||
ApiRouter.get('/logout', auth.authenticate, UserController.logout);
|
||||
ApiRouter.post('/changepassword', auth.authenticate, existance.userExist, UserController.changePassword);
|
||||
|
||||
ApiRouter.post('/uploadSkin', existance.userExist, auth.authenticate, utils.upload.single('file'), requiredParameters.requireFile, UserController.uploadSkin);
|
||||
ApiRouter.post('/uploadCape', existance.userExist, auth.authenticate, auth.canHaveCloak, utils.upload.single('file'), requiredParameters.requireFile, UserController.uploadCape);
|
||||
|
||||
ApiRouter.get('/getUsername', existance.userExist, auth.authenticate, UserController.getUsername);
|
||||
ApiRouter.get('/getChatMessages/:offset/:limit', auth.authenticate, ApiController.getChatMessages);
|
||||
ApiRouter.get('/webSocketConnection', auth.authenticate, ApiController.getWebsocketConnection)
|
||||
ApiRouter.get('/webSocketConnection', auth.authenticate, ApiController.getWebsocketConnection);
|
||||
|
||||
export default ApiRouter;
|
||||
ApiRouter.get('/skinsUrl', auth.authenticate, ApiController.getSkinsUrl);
|
||||
ApiRouter.get('/capesUrl', auth.authenticate, ApiController.getCapesUrl);
|
||||
|
||||
export default ApiRouter;
|
||||
|
||||
@@ -1,25 +1,23 @@
|
||||
import { Router } from 'express';
|
||||
import jwt from 'jsonwebtoken';
|
||||
import dotenv from 'dotenv';
|
||||
|
||||
import auth from '../middlewares/auth.js';
|
||||
import UserService from '../services/user.js';
|
||||
|
||||
dotenv.config({path: ".env"});
|
||||
import config from '../config.js';
|
||||
|
||||
const UserRouter = new Router();
|
||||
|
||||
UserRouter.get('/register', async (req, res) => {
|
||||
if (req.cookies["jwt"] && jwt.verify(req.cookies["jwt"], process.env.SECRET))
|
||||
if (req.cookies["jwt"] && jwt.verify(req.cookies["jwt"], config.secret))
|
||||
return res.redirect("/index");
|
||||
|
||||
return res.render("register.pug", {
|
||||
require_token: process.env.REQUIRE_TOKEN == "true"? true : false
|
||||
require_token: config.require_token? true : false
|
||||
});
|
||||
});
|
||||
|
||||
UserRouter.get(['/', '/login'], async (req, res) => {
|
||||
if(req.cookies["jwt"] && jwt.verify(req.cookies["jwt"], process.env.SECRET)) {
|
||||
if(req.cookies["jwt"] && jwt.verify(req.cookies["jwt"], config.secret)) {
|
||||
return res.redirect("/index");
|
||||
}
|
||||
|
||||
@@ -31,7 +29,9 @@ UserRouter.get(['/index', '/skin'], auth.authenticate, async (req, res) => {
|
||||
|
||||
return res.render('skin.pug', {
|
||||
username: username,
|
||||
can_have_cloak: await UserService.canHaveCloak(username)
|
||||
can_have_cloak: await UserService.canHaveCloak(username),
|
||||
enable_chat: config.enable_chat,
|
||||
enable_worldmap: config.enable_worldmap
|
||||
});
|
||||
});
|
||||
|
||||
@@ -39,7 +39,9 @@ UserRouter.get('/changepassword', auth.authenticate, async (req, res) => {
|
||||
const username = jwt.decode(req.cookies["jwt"]).username;
|
||||
|
||||
return res.render('changepassword.pug', {
|
||||
can_have_cloak: await UserService.canHaveCloak(username)
|
||||
can_have_cloak: await UserService.canHaveCloak(username),
|
||||
enable_chat: config.enable_chat,
|
||||
enable_worldmap: config.enable_worldmap
|
||||
});
|
||||
});
|
||||
|
||||
@@ -47,7 +49,9 @@ UserRouter.get('/chat', auth.authenticate, async (req, res) => {
|
||||
const username = jwt.decode(req.cookies["jwt"]).username;
|
||||
|
||||
return res.render('chat.pug', {
|
||||
can_have_cloak: await UserService.canHaveCloak(username)
|
||||
can_have_cloak: await UserService.canHaveCloak(username),
|
||||
enable_chat: config.enable_chat,
|
||||
enable_worldmap: config.enable_worldmap
|
||||
});
|
||||
});
|
||||
|
||||
@@ -55,8 +59,11 @@ UserRouter.get('/worldmap', auth.authenticate, async (req, res) => {
|
||||
const username = jwt.decode(req.cookies["jwt"]).username;
|
||||
|
||||
return res.render('worldmap.pug', {
|
||||
can_have_cloak: await UserService.canHaveCloak(username)
|
||||
can_have_cloak: await UserService.canHaveCloak(username),
|
||||
enable_worldmap: config.enable_worldmap,
|
||||
enable_chat: config.enable_chat,
|
||||
worldmap_url: config.worldmap_url
|
||||
});
|
||||
});
|
||||
|
||||
export default UserRouter;
|
||||
export default UserRouter;
|
||||
|
||||
@@ -6,6 +6,8 @@ div(class="action-tabs")
|
||||
else
|
||||
button(class="actionTabButton" id="skinsTabButton" onclick="goToPage('/index')") Скин
|
||||
button(class="actionTabButton" id="passwordChangeTabButton" onclick="goToPage('/changepassword')") Сменить пароль
|
||||
button(class="actionTabButton" id="chatTabButton" onclick="goToPage('/chat')") Чат
|
||||
button(class="actionTabButton" id="chatTabButton" onclick="goToPage('/worldmap')") Карта мира
|
||||
button(class="actionTabButton logoutTabButton" id="logoutTabButton" onclick="window.location.href='/api/logout'") Выйти
|
||||
if (enable_chat)
|
||||
button(class="actionTabButton" id="chatTabButton" onclick="goToPage('/chat')") Чат
|
||||
if (enable_worldmap)
|
||||
button(class="actionTabButton" id="chatTabButton" onclick="goToPage('/worldmap')") Карта мира
|
||||
button(class="actionTabButton logoutTabButton" id="logoutTabButton" onclick="window.location.href='/api/logout'") Выйти
|
||||
|
||||
@@ -10,4 +10,4 @@ html
|
||||
div(class="content-container")
|
||||
div(class="map-container")
|
||||
h1 Карта
|
||||
p Пока что тут пусто, но скоро будет кое-что интересное!
|
||||
iframe(src=worldmap_url class="map-container")
|
||||
|
||||
Reference in New Issue
Block a user