Update permissions.
parent
f1db3d0451
commit
dd2d9dc3f5
|
@ -35,7 +35,7 @@ export function isValidToken(token, validation) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function allowQuery(req, type) {
|
export async function allowQuery(req, type, allowShareToken = true) {
|
||||||
const { id } = req.query;
|
const { id } = req.query;
|
||||||
|
|
||||||
const { userId, isAdmin, shareToken } = req.auth ?? {};
|
const { userId, isAdmin, shareToken } = req.auth ?? {};
|
||||||
|
@ -44,7 +44,7 @@ export async function allowQuery(req, type) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shareToken) {
|
if (allowShareToken && shareToken) {
|
||||||
return isValidToken(shareToken, { id });
|
return isValidToken(shareToken, { id });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ export default async (req, res) => {
|
||||||
const { current_password, new_password } = req.body;
|
const { current_password, new_password } = req.body;
|
||||||
const { id: accountUuid } = req.query;
|
const { id: accountUuid } = req.query;
|
||||||
|
|
||||||
if (!(await allowQuery(req, TYPE_ACCOUNT))) {
|
if (!(await allowQuery(req, TYPE_ACCOUNT, false))) {
|
||||||
return unauthorized(res);
|
return unauthorized(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,8 @@ export default async (req, res) => {
|
||||||
await useAuth(req, res);
|
await useAuth(req, res);
|
||||||
|
|
||||||
const { id: websiteUuid } = req.query;
|
const { id: websiteUuid } = req.query;
|
||||||
const { userId } = req.auth;
|
|
||||||
|
|
||||||
if (!userId || !(await allowQuery(req, TYPE_WEBSITE))) {
|
if (!(await allowQuery(req, TYPE_WEBSITE, false))) {
|
||||||
return unauthorized(res);
|
return unauthorized(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ export default async (req, res) => {
|
||||||
const { id: websiteId } = req.query;
|
const { id: websiteId } = req.query;
|
||||||
|
|
||||||
if (req.method === 'POST') {
|
if (req.method === 'POST') {
|
||||||
if (!(await allowQuery(req, TYPE_WEBSITE))) {
|
if (!(await allowQuery(req, TYPE_WEBSITE, false))) {
|
||||||
return unauthorized(res);
|
return unauthorized(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue