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:
parent
6039002ed5
commit
7bd1c6e115
4 changed files with 16 additions and 5 deletions
web/src/app
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue