Add database migration.

This commit is contained in:
Brian Cao 2022-11-29 21:56:43 -08:00
parent 0a9089a463
commit 77b739870e
5 changed files with 360 additions and 6 deletions

View file

@ -34,6 +34,13 @@ export function parseShareToken(req) {
}
}
export function hasPermission(
value: UmamiApi.Role | UmamiApi.Permission,
permissions: UmamiApi.Role[] | UmamiApi.Permission[],
) {
return permissions.some(a => a === value);
}
export function isValidToken(token, validation) {
try {
if (typeof validation === 'object') {
@ -85,7 +92,6 @@ export async function allowQuery(
const teamUser = await getTeamUser({
userId: user.id,
teamId: typeId ?? id,
isDeleted: false,
});
return teamUser;
@ -93,10 +99,12 @@ export async function allowQuery(
const teamUser = await getTeamUser({
userId: user.id,
teamId: typeId ?? id,
isDeleted: false,
});
return teamUser && teamUser.isOwner;
return (
teamUser &&
(teamUser.roleId === UmamiApi.Role.TeamOwner || teamUser.roleId === UmamiApi.Role.Admin)
);
}
}