mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-08-20 14:42:37 +02:00
feat: add user from, show deparments, users in pages
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
export default async function getUserByOrg(req) {
|
||||
const OrganizationId = req.params.organizationId;
|
||||
const orgPtr = {
|
||||
__type: 'Pointer',
|
||||
className: 'contracts_Organizations',
|
||||
objectId: OrganizationId,
|
||||
};
|
||||
if (!req?.user) {
|
||||
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'User is not authenticated.');
|
||||
} else {
|
||||
try {
|
||||
const extUser = new Parse.Query('contracts_Users');
|
||||
extUser.include('DepartmentIds');
|
||||
extUser.equalTo('OrganizationId', orgPtr);
|
||||
const userRes = await extUser.first({ useMasterKey: true });
|
||||
if (userRes.length > 0) {
|
||||
const _userRes = JSON.parse(JSON.stringify(userRes));
|
||||
return _userRes;
|
||||
} else {
|
||||
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'User not found.');
|
||||
}
|
||||
} catch (err) {
|
||||
console.log('err in getuserlist', err);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user