moved skins&capes target paths to config
This commit is contained in:
parent
c282c6b597
commit
a805cb77fc
|
@ -20,3 +20,11 @@ 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
|
|
@ -21,7 +21,13 @@ const config = {
|
|||
ws_connection_string: process.env.WS_CONNECTION_STRING,
|
||||
|
||||
enable_worldmap: getBoolean(process.env.ENABLE_WORLDMAP),
|
||||
worldmap_url: process.env.WORLDMAP_URL
|
||||
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;
|
|
@ -76,13 +76,12 @@ 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) {
|
||||
return res.status(400).send('This does not look like a minecraft skin.');
|
||||
|
@ -98,13 +97,12 @@ 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);
|
||||
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.');
|
||||
|
|
Loading…
Reference in New Issue