0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 12:02:48 +00:00

fixes as asked

This commit is contained in:
Víctor Losada Hernández
2024-12-14 23:34:12 +01:00
parent afc92c4545
commit 99f2972079
3 changed files with 15 additions and 25 deletions

View File

@@ -280,7 +280,6 @@ app.get('/css/:id', asyncHandler(getBrew('share')), (req, res)=>{getCSS(req, res
//User Page
app.get('/user/:username', async (req, res, next)=>{
const ownAccount = req.account && (req.account.username == req.params.username);
console.log(req.account);
req.ogMeta = { ...defaultMetaTags,
title : `${req.params.username}'s Collection`,
@@ -352,7 +351,6 @@ app.get('/user/:username', async (req, res, next)=>{
//Change author name on brews
app.put('/api/user/rename', async (req, res)=>{
console.log(req.account);
const { username, newUsername } = req.body;
console.log(`is user ${req.account.username} equal to ${username}? ${req.account.username === username} ${req.account.username === username && 'then add the damn auth for renaming!'}`);
console.log('renaming');

View File

@@ -467,12 +467,11 @@ const api = {
}
};
router.use('/api', checkClientVersion);
router.post('/api', asyncHandler(api.newBrew));
router.put('/api/:id', asyncHandler(api.getBrew('edit', true)), asyncHandler(api.updateBrew));
router.put('/api/update/:id', asyncHandler(api.getBrew('edit', true)), asyncHandler(api.updateBrew));
router.delete('/api/:id', asyncHandler(api.deleteBrew));
router.get('/api/remove/:id', asyncHandler(api.deleteBrew));
router.post('/api', checkClientVersion, asyncHandler(api.newBrew));
router.put('/api/:id', checkClientVersion, asyncHandler(api.getBrew('edit', true)), asyncHandler(api.updateBrew));
router.put('/api/update/:id', checkClientVersion, asyncHandler(api.getBrew('edit', true)), asyncHandler(api.updateBrew));
router.delete('/api/:id', checkClientVersion, asyncHandler(api.deleteBrew));
router.get('/api/remove/:id', checkClientVersion, asyncHandler(api.deleteBrew));
router.get('/api/theme/:renderer/:id', asyncHandler(api.getThemeBundle));
export default api;

View File

@@ -1,22 +1,15 @@
import packageJSON from '../../package.json' with { type: "json" };
import packageJSON from '../../package.json' with { type: 'json' };
export default (req, res, next) => {
const origin = req.get('Origin');
const sameSite = req.get('Host');
export default (req, res, next)=>{
const userVersion = req.get('Homebrewery-Version');
const version = packageJSON.version;
if (origin && origin !== `http://${sameSite}` && origin !== `https://${sameSite}`) {
return next(); // Skip version check if the request is from another site, like naturalcrit.com
}
if(userVersion !== version) {
return res.status(412).send({
message : `Client version ${userVersion} is out of date. Please save your changes elsewhere and refresh to pick up client version ${version}.`
});
}
const userVersion = req.get('Homebrewery-Version');
const version = packageJSON.version;
if (userVersion !== version) {
return res.status(412).send({
message: `Client version ${userVersion} is out of date. Please save your changes elsewhere and refresh to pick up client version ${version}.`
});
}
next();
next();
};