mirror of
https://github.com/binwiederhier/ntfy.git
synced 2025-06-18 18:43:15 +02:00
Token stuff
This commit is contained in:
parent
d3dfeeccc3
commit
d499d20a9c
8 changed files with 194 additions and 64 deletions
web/src/app
|
@ -1,11 +1,13 @@
|
|||
import {
|
||||
fetchLinesIterator,
|
||||
maybeWithBasicAuth,
|
||||
maybeWithBasicAuth, maybeWithBearerAuth,
|
||||
topicShortUrl,
|
||||
topicUrl,
|
||||
topicUrlAuth,
|
||||
topicUrlJsonPoll,
|
||||
topicUrlJsonPollWithSince, userAuthUrl,
|
||||
topicUrlJsonPollWithSince,
|
||||
userAccountUrl,
|
||||
userAuthUrl,
|
||||
userStatsUrl
|
||||
} from "./utils";
|
||||
import userManager from "./UserManager";
|
||||
|
@ -144,6 +146,20 @@ class Api {
|
|||
console.log(`[Api] Stats`, stats);
|
||||
return stats;
|
||||
}
|
||||
|
||||
async userAccount(baseUrl, token) {
|
||||
const url = userAccountUrl(baseUrl);
|
||||
console.log(`[Api] Fetching user account ${url}`);
|
||||
const response = await fetch(url, {
|
||||
headers: maybeWithBearerAuth({}, token)
|
||||
});
|
||||
if (response.status !== 200) {
|
||||
throw new Error(`Unexpected server response ${response.status}`);
|
||||
}
|
||||
const account = await response.json();
|
||||
console.log(`[Api] Account`, account);
|
||||
return account;
|
||||
}
|
||||
}
|
||||
|
||||
const api = new Api();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue