mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
api and lib fixes (#1643)
This commit is contained in:
parent
168283bf11
commit
13fd3ccd16
9 changed files with 30 additions and 29 deletions
|
|
@ -10,7 +10,7 @@ export default async (req, res) => {
|
|||
if (req.method === 'GET') {
|
||||
const { userId } = req.auth;
|
||||
|
||||
const websites = await getUserWebsites({ userId });
|
||||
const websites = await getUserWebsites(userId);
|
||||
const ids = websites.map(({ id }) => id);
|
||||
const token = createToken({ websites: ids }, secret());
|
||||
const data = await getRealtimeData(ids, subMinutes(new Date(), 30));
|
||||
|
|
|
|||
|
|
@ -7,12 +7,13 @@ export default async (req, res) => {
|
|||
await useCors(req, res);
|
||||
await useAuth(req, res);
|
||||
|
||||
const { id, isAdmin } = req.auth;
|
||||
const { userId, isAdmin } = req.auth;
|
||||
|
||||
if (req.method === 'GET') {
|
||||
const { include_all } = req.query;
|
||||
|
||||
const websites = isAdmin && include_all ? await getAllWebsites() : await getUserWebsites(id);
|
||||
const websites =
|
||||
isAdmin && include_all ? await getAllWebsites() : await getUserWebsites(userId);
|
||||
|
||||
return ok(res, websites);
|
||||
}
|
||||
|
|
@ -21,7 +22,7 @@ export default async (req, res) => {
|
|||
const { name, domain, enableShareUrl } = req.body;
|
||||
|
||||
const shareId = enableShareUrl ? getRandomChars(8) : null;
|
||||
const website = await createWebsite(id, { id: uuid(), name, domain, shareId });
|
||||
const website = await createWebsite(userId, { id: uuid(), name, domain, shareId });
|
||||
|
||||
return ok(res, website);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue