Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Mike Cao 2024-02-02 17:49:30 -08:00
commit a91b9c9716
5 changed files with 22 additions and 8 deletions

View File

@ -1,4 +1,4 @@
name: "🐛 Bug Report"
name: '🐛 Bug Report'
description: Create a bug report for Umami.
body:
- type: textarea
@ -22,6 +22,10 @@ body:
label: Relevant log output
description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
render: shell
- type: input
attributes:
label: Which Umami version are you using? (if relevant)
description: 'For example: Chrome, Edge, Firefox, etc'
- type: input
attributes:
label: Which browser are you using? (if relevant)
@ -29,4 +33,4 @@ body:
- type: input
attributes:
label: How are you deploying your application? (if relevant)
description: 'For example: Vercel, Railway, Docker, etc'
description: 'For example: Vercel, Railway, Docker, etc'

View File

@ -1,6 +1,6 @@
{
"name": "@umami/components",
"version": "0.1.0",
"version": "0.40.0",
"description": "Umami React components.",
"author": "Mike Cao <mike@mikecao.com>",
"license": "MIT",

View File

@ -10,7 +10,7 @@ export interface FilterQueryResult<T> {
setParams: Dispatch<SetStateAction<T | SearchFilter>>;
}
export function useFilterQuery<T>({
export function useFilterQuery<T = any>({
queryKey,
queryFn,
...options

View File

@ -166,14 +166,14 @@ export async function canViewTeam({ user }: Auth, teamId: string) {
}
export async function canUpdateTeam({ user, grant }: Auth, teamId: string) {
if (cloudMode) {
return !!grant?.find(a => a === PERMISSIONS.teamUpdate);
}
if (user.isAdmin) {
return true;
}
if (cloudMode) {
return !!grant?.find(a => a === PERMISSIONS.teamUpdate);
}
const teamUser = await getTeamUser(teamId, user.id);
return teamUser && hasPermission(teamUser.role, PERMISSIONS.teamUpdate);

View File

@ -37,6 +37,16 @@ export default async (
const { teamId, userId } = req.query;
if (req.method === 'GET') {
if (!(await canUpdateTeam(req.auth, teamId))) {
return unauthorized(res, 'You must be the owner of this team.');
}
const teamUser = await getTeamUser(teamId, userId);
return ok(res, teamUser);
}
if (req.method === 'POST') {
if (!(await canUpdateTeam(req.auth, teamId))) {
return unauthorized(res, 'You must be the owner of this team.');