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