mirror of
https://github.com/kremalicious/umami.git
synced 2024-06-30 05:31:50 +02:00
Remove webisite.teamId related code. Clean up queries.
This commit is contained in:
parent
081a126c01
commit
0335fd3529
|
@ -95,17 +95,11 @@ export async function canViewWebsite({ user, shareToken }: Auth, websiteId: stri
|
|||
return false;
|
||||
}
|
||||
|
||||
export async function canCreateWebsite({ user }: Auth, teamId?: string) {
|
||||
export async function canCreateWebsite({ user }: Auth) {
|
||||
if (user.isAdmin) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (teamId) {
|
||||
const teamUser = await getTeamUser(teamId, user.id);
|
||||
|
||||
return hasPermission(teamUser?.role, PERMISSIONS.websiteCreate);
|
||||
}
|
||||
|
||||
return hasPermission(user.role, PERMISSIONS.websiteCreate);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,15 +41,17 @@ export default async (
|
|||
|
||||
const { name, domain, shareId } = req.body;
|
||||
|
||||
let website;
|
||||
|
||||
try {
|
||||
await updateWebsite(websiteId, { name, domain, shareId });
|
||||
website = await updateWebsite(websiteId, { name, domain, shareId });
|
||||
} catch (e: any) {
|
||||
if (e.message.includes('Unique constraint') && e.message.includes('share_id')) {
|
||||
return serverError(res, 'That share ID is already taken.');
|
||||
}
|
||||
}
|
||||
|
||||
return ok(res);
|
||||
return ok(res, website);
|
||||
}
|
||||
|
||||
if (req.method === 'DELETE') {
|
||||
|
|
|
@ -10,7 +10,6 @@ export interface WebsitesRequestBody {
|
|||
name: string;
|
||||
domain: string;
|
||||
shareId: string;
|
||||
teamId?: string;
|
||||
}
|
||||
|
||||
export default async (
|
||||
|
@ -31,9 +30,9 @@ export default async (
|
|||
}
|
||||
|
||||
if (req.method === 'POST') {
|
||||
const { name, domain, shareId, teamId } = req.body;
|
||||
const { name, domain, shareId } = req.body;
|
||||
|
||||
if (!(await canCreateWebsite(req.auth, teamId))) {
|
||||
if (!(await canCreateWebsite(req.auth))) {
|
||||
return unauthorized(res);
|
||||
}
|
||||
|
||||
|
@ -44,11 +43,7 @@ export default async (
|
|||
shareId,
|
||||
};
|
||||
|
||||
if (teamId) {
|
||||
data.teamId = teamId;
|
||||
} else {
|
||||
data.userId = userId;
|
||||
}
|
||||
|
||||
const website = await createWebsite(data);
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ export async function getEventMetrics(
|
|||
endDate: Date;
|
||||
timezone: string;
|
||||
unit: string;
|
||||
column: string;
|
||||
filters: {
|
||||
url: string;
|
||||
eventName: string;
|
||||
|
@ -40,7 +39,6 @@ async function relationalQuery(
|
|||
endDate: Date;
|
||||
timezone: string;
|
||||
unit: string;
|
||||
column: string;
|
||||
filters: {
|
||||
url: string;
|
||||
eventName: string;
|
||||
|
|
Loading…
Reference in New Issue
Block a user