This commit is contained in:
asyncnomi 2023-01-10 09:25:06 +01:00
parent f933456c22
commit b5bf2a347b

View file

@ -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