From b5bf2a347bae3f495c114246cccd41236262ace5 Mon Sep 17 00:00:00 2001 From: asyncnomi Date: Tue, 10 Jan 2023 09:25:06 +0100 Subject: [PATCH] bla --- index.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index b5a043a..a27ea22 100644 --- a/index.js +++ b/index.js @@ -141,15 +141,22 @@ fastify.post('/switchState', async (request, reply) => { let content = request.body; let auth = checkAuthetification(content); if (auth.success) { - if (ServiceState.state == "closed") { - ServiceState.state = "open"; + if (AdminUsersUid.includes(content.uid)) { + if (ServiceState.state == "closed") { + ServiceState.state = "open"; + } else { + ServiceState.state = "closed"; + } + saveData(servicePath, ServiceState); + return { + success: true, + state: ServiceState.state + } } else { - ServiceState.state = "closed"; - } - saveData(servicePath, ServiceState); - return { - success: true, - state: ServiceState.state + return { + success: false, + why: "Not allowed" + } } } else { return auth