mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Allow admins to view account websites.
This commit is contained in:
parent
cb14b8bbda
commit
5a22be5efa
19 changed files with 57 additions and 35 deletions
|
|
@ -1,11 +1,14 @@
|
|||
import React from 'react';
|
||||
import Layout from 'components/layout/Layout';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
|
||||
export default function Custom404() {
|
||||
return (
|
||||
<Layout>
|
||||
<div className="row justify-content-center">
|
||||
<h1>oops! page not found</h1>
|
||||
<h1>
|
||||
<FormattedMessage id="message.page-not-found" defaultMessage="Page not found" />
|
||||
</h1>
|
||||
</div>
|
||||
</Layout>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,18 +0,0 @@
|
|||
import React from 'react';
|
||||
import Layout from 'components/layout/Layout';
|
||||
import AccountSettings from 'components/settings/AccountSettings';
|
||||
import useRequireLogin from 'hooks/useRequireLogin';
|
||||
|
||||
export default function AccountPage() {
|
||||
const { loading } = useRequireLogin();
|
||||
|
||||
if (loading) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<Layout>
|
||||
<AccountSettings />
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,14 +1,19 @@
|
|||
import { getUserWebsites } from 'lib/queries';
|
||||
import { useAuth } from 'lib/middleware';
|
||||
import { ok, methodNotAllowed } from 'lib/response';
|
||||
import { ok, methodNotAllowed, unauthorized } from 'lib/response';
|
||||
|
||||
export default async (req, res) => {
|
||||
await useAuth(req, res);
|
||||
|
||||
const { user_id } = req.auth;
|
||||
const { user_id, is_admin } = req.auth;
|
||||
const { userId } = req.query;
|
||||
|
||||
if (req.method === 'GET') {
|
||||
const websites = await getUserWebsites(user_id);
|
||||
if (userId && !is_admin) {
|
||||
return unauthorized(res);
|
||||
}
|
||||
|
||||
const websites = await getUserWebsites(+userId || user_id);
|
||||
|
||||
return ok(res, websites);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,14 @@
|
|||
import React from 'react';
|
||||
import { useRouter } from 'next/router';
|
||||
import Layout from 'components/layout/Layout';
|
||||
import WebsiteList from 'components/WebsiteList';
|
||||
import useRequireLogin from 'hooks/useRequireLogin';
|
||||
|
||||
export default function DashboardPage() {
|
||||
const { loading } = useRequireLogin();
|
||||
const router = useRouter();
|
||||
const { id } = router.query;
|
||||
const userId = id?.[0];
|
||||
|
||||
if (loading) {
|
||||
return null;
|
||||
|
|
@ -12,7 +16,7 @@ export default function DashboardPage() {
|
|||
|
||||
return (
|
||||
<Layout>
|
||||
<WebsiteList />
|
||||
<WebsiteList userId={userId} />
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue