mirror of
https://github.com/Threnklyn/wg-ui.git
synced 2026-05-21 14:23:31 +02:00
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:
+13
-3
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user