0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 18:32:41 +00:00

Add overwrite option to API function

This commit is contained in:
G.Ambatte
2025-04-07 22:02:53 +12:00
parent f8566392f6
commit ec6258a2a5

View File

@@ -208,6 +208,10 @@ router.get('/api/locks', mw.adminOnly, asyncHandler(async (req, res)=>{
router.post('/api/lock/:id', mw.adminOnly, asyncHandler(async (req, res)=>{
const lock = req.body;
const overwrite = lock.overwrite || false;
lock.overwrite = undefined;
lock.applied = new Date;
const filter = {
@@ -218,7 +222,7 @@ router.post('/api/lock/:id', mw.adminOnly, asyncHandler(async (req, res)=>{
if(!brew) throw { name: 'Brew Not Found', message: 'Cannot find brew to lock', shareId: req.params.id, status: 500, HBErrorCode: '63' };
if(brew.lock) {
if(brew.lock && !overwrite) {
// console.log('ALREADY LOCKED');
throw { name: 'Already Locked', message: 'Lock already exists on brew', shareId: req.params.id, title: brew.title, status: 500, HBErrorCode: '64' };
}