1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2025-06-18 18:43:15 +02:00

Check username taken

This commit is contained in:
binwiederhier 2022-12-24 08:15:39 -05:00
parent 6039002ed5
commit 7bd1c6e115
4 changed files with 16 additions and 5 deletions
web/src/app

View file

@ -160,6 +160,9 @@ class Api {
method: "POST",
body: body
});
if (response.status === 409) {
throw new UsernameTakenError(username)
}
if (response.status !== 200) {
throw new Error(`Unexpected server response ${response.status}`);
}
@ -250,5 +253,12 @@ class Api {
}
}
export class UsernameTakenError extends Error {
constructor(username) {
super();
this.username = username;
}
}
const api = new Api();
export default api;