Add limit in how many configurations each user may have. (#47)

* Add limit in how many configurations each user may have.

If the option max-number-client-config is more than 0 this number is the
maximum number of clients a user can create.

The setting only limits creation. If a user had created more
configurations before this setting is enforced or lowered the user may
user the service as before, just cant create any more configurations.

* Fix spelling and fmt as suggested by @luna-duclos

* Alert user when limit is reached.

When the user tries to create more configurations than are allow an
alert will pop up.

* Change http status as discussed with @freddd

http 400 seems a better fit than 429 as a more generic error.
This commit is contained in:
Björn Bohman
2020-03-20 15:09:01 +01:00
committed by GitHub
parent 005b2413b7
commit fb5cf90751
2 changed files with 41 additions and 8 deletions
+13 -3
View File
@@ -17,12 +17,22 @@
async function handleNewClick(event) {
const res = await fetch(clientsUrl, {
method: "POST",
});
let newClient = await res.json();
console.log("New client added", newClient);
})
.then(response => {
return response.json()
})
.then(data => {
if (typeof data.Error != "undefined") {
console.log(data.Error);
alert(data.Error);
} else {
console.log("New client added", data);
}
});
await getClients();
}
onMount(getClients);
</script>