mirror of
https://github.com/binwiederhier/ntfy.git
synced 2025-06-18 10:33:11 +02:00
Change password, delete account, etc.
This commit is contained in:
parent
8ff168283c
commit
81a8efcca3
14 changed files with 628 additions and 214 deletions
web/src/app
|
@ -8,7 +8,7 @@ import {
|
|||
topicUrlJsonPollWithSince,
|
||||
accountSettingsUrl,
|
||||
accountTokenUrl,
|
||||
userStatsUrl, accountSubscriptionUrl, accountSubscriptionSingleUrl, accountUrl
|
||||
userStatsUrl, accountSubscriptionUrl, accountSubscriptionSingleUrl, accountUrl, accountPasswordUrl
|
||||
} from "./utils";
|
||||
import userManager from "./UserManager";
|
||||
|
||||
|
@ -175,6 +175,33 @@ class Api {
|
|||
}
|
||||
}
|
||||
|
||||
async deleteAccount(baseUrl, token) {
|
||||
const url = accountUrl(baseUrl);
|
||||
console.log(`[Api] Deleting user account ${url}`);
|
||||
const response = await fetch(url, {
|
||||
method: "DELETE",
|
||||
headers: maybeWithBearerAuth({}, token)
|
||||
});
|
||||
if (response.status !== 200) {
|
||||
throw new Error(`Unexpected server response ${response.status}`);
|
||||
}
|
||||
}
|
||||
|
||||
async changePassword(baseUrl, token, password) {
|
||||
const url = accountPasswordUrl(baseUrl);
|
||||
console.log(`[Api] Changing account password ${url}`);
|
||||
const response = await fetch(url, {
|
||||
method: "POST",
|
||||
headers: maybeWithBearerAuth({}, token),
|
||||
body: JSON.stringify({
|
||||
password: password
|
||||
})
|
||||
});
|
||||
if (response.status !== 200) {
|
||||
throw new Error(`Unexpected server response ${response.status}`);
|
||||
}
|
||||
}
|
||||
|
||||
async getAccountSettings(baseUrl, token) {
|
||||
const url = accountSettingsUrl(baseUrl);
|
||||
console.log(`[Api] Fetching user account ${url}`);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue