mirror of
https://github.com/umami-software/umami.git
synced 2026-02-11 16:17:13 +01:00
Enable public website sharing.
This commit is contained in:
parent
48a524e09c
commit
560f1316c1
36 changed files with 294 additions and 61 deletions
|
|
@ -3,9 +3,6 @@ import { useAuth } from 'lib/middleware';
|
|||
import { methodNotAllowed, ok, unauthorized } from 'lib/response';
|
||||
|
||||
export default async (req, res) => {
|
||||
await useAuth(req, res);
|
||||
|
||||
const { user_id, is_admin } = req.auth;
|
||||
const { id } = req.query;
|
||||
const website_id = +id;
|
||||
|
||||
|
|
@ -16,6 +13,9 @@ export default async (req, res) => {
|
|||
}
|
||||
|
||||
if (req.method === 'DELETE') {
|
||||
await useAuth(req, res);
|
||||
const { user_id, is_admin } = req.auth;
|
||||
|
||||
const website = await getWebsiteById(website_id);
|
||||
|
||||
if (website.user_id === user_id || is_admin) {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
import { getMetrics } from 'lib/queries';
|
||||
import { useAuth } from 'lib/middleware';
|
||||
import { ok } from 'lib/response';
|
||||
|
||||
export default async (req, res) => {
|
||||
await useAuth(req, res);
|
||||
|
||||
const { id, start_at, end_at } = req.query;
|
||||
|
||||
const metrics = await getMetrics(+id, new Date(+start_at), new Date(+end_at));
|
||||
|
|
|
|||
|
|
@ -1,13 +1,10 @@
|
|||
import moment from 'moment-timezone';
|
||||
import { getPageviews } from 'lib/queries';
|
||||
import { useAuth } from 'lib/middleware';
|
||||
import { ok, badRequest } from 'lib/response';
|
||||
|
||||
const unitTypes = ['month', 'hour', 'day'];
|
||||
|
||||
export default async (req, res) => {
|
||||
await useAuth(req, res);
|
||||
|
||||
const { id, start_at, end_at, unit, tz } = req.query;
|
||||
|
||||
if (!moment.tz.zone(tz) || !unitTypes.includes(unit)) {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,10 @@
|
|||
import { getRankings } from 'lib/queries';
|
||||
import { useAuth } from 'lib/middleware';
|
||||
import { ok, badRequest } from 'lib/response';
|
||||
|
||||
const sessionColumns = ['browser', 'os', 'device', 'country'];
|
||||
const pageviewColumns = ['url', 'referrer'];
|
||||
|
||||
export default async (req, res) => {
|
||||
await useAuth(req, res);
|
||||
|
||||
const { id, type, start_at, end_at } = req.query;
|
||||
|
||||
if (!sessionColumns.includes(type) && !pageviewColumns.includes(type)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue