mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Fixed issue with accessing user dashboards. Closes #1590
This commit is contained in:
parent
46a18f2918
commit
8b64ef1a4e
8 changed files with 33 additions and 25 deletions
|
|
@ -21,9 +21,9 @@ export default async (req, res) => {
|
|||
if (req.method === 'POST') {
|
||||
const { username, password, account_uuid } = req.body;
|
||||
|
||||
const accountByUsername = await getAccount({ username });
|
||||
const account = await getAccount({ username });
|
||||
|
||||
if (accountByUsername) {
|
||||
if (account) {
|
||||
return badRequest(res, 'Account already exists');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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(({ websiteUuid }) => websiteUuid);
|
||||
const token = createToken({ websites: ids }, secret());
|
||||
const data = await getRealtimeData(ids, subMinutes(new Date(), 30));
|
||||
|
|
|
|||
|
|
@ -6,15 +6,16 @@ import { uuid } from 'lib/crypto';
|
|||
export default async (req, res) => {
|
||||
await useAuth(req, res);
|
||||
|
||||
const { userId: currentUserId, isAdmin, accountUuid } = req.auth;
|
||||
const { user_id, include_all } = req.query;
|
||||
const { userId: currentUserId, isAdmin } = req.auth;
|
||||
const accountUuid = user_id || req.auth.accountUuid;
|
||||
let account;
|
||||
|
||||
if (accountUuid) {
|
||||
account = await getAccount({ accountUuid: accountUuid });
|
||||
account = await getAccount({ accountUuid });
|
||||
}
|
||||
|
||||
const userId = account ? account.id : +user_id;
|
||||
const userId = account ? account.id : user_id;
|
||||
|
||||
if (req.method === 'GET') {
|
||||
if (userId && userId !== currentUserId && !isAdmin) {
|
||||
|
|
@ -24,7 +25,7 @@ export default async (req, res) => {
|
|||
const websites =
|
||||
isAdmin && include_all
|
||||
? await getAllWebsites()
|
||||
: await getUserWebsites(userId || currentUserId);
|
||||
: await getUserWebsites({ userId: account.id });
|
||||
|
||||
return ok(res, websites);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue