mirror of
https://github.com/fosrl/pangolin.git
synced 2025-07-19 18:24:43 +02:00
add user checks in routes
This commit is contained in:
parent
f8e0219b49
commit
a9f0b9aa38
21 changed files with 302 additions and 133 deletions
|
@ -49,7 +49,7 @@ export async function addUserRole(
|
|||
|
||||
const { userId, roleId } = parsedParams.data;
|
||||
|
||||
if (!req.userOrg) {
|
||||
if (req.user && !req.userOrg) {
|
||||
return next(
|
||||
createHttpError(
|
||||
HttpCode.FORBIDDEN,
|
||||
|
@ -58,7 +58,13 @@ export async function addUserRole(
|
|||
);
|
||||
}
|
||||
|
||||
const orgId = req.userOrg.orgId;
|
||||
const orgId = req.userOrg?.orgId || req.apiKeyOrg?.orgId;
|
||||
|
||||
if (!orgId) {
|
||||
return next(
|
||||
createHttpError(HttpCode.BAD_REQUEST, "Invalid organization ID")
|
||||
);
|
||||
}
|
||||
|
||||
const existingUser = await db
|
||||
.select()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue