mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-08-22 15:42:31 +02:00
feat : add cloud function for public sign
This commit is contained in:
@@ -4,8 +4,12 @@ async function GetPublicTemplate(request) {
|
||||
if (username) {
|
||||
const extUserQuery = new Parse.Query('contracts_Users');
|
||||
extUserQuery.equalTo('UserName', username);
|
||||
const res = await extUserQuery.first({ useMasterKey: true });
|
||||
const userId = res.get('UserId').id;
|
||||
const userRes = await extUserQuery.first({ useMasterKey: true });
|
||||
const userId = userRes.get('UserId').id;
|
||||
|
||||
//get _user details
|
||||
const userQuery = new Parse.Query(Parse.User);
|
||||
const user = await userQuery.get(userId, { useMasterKey: true });
|
||||
if (userId) {
|
||||
const templatQuery = new Parse.Query('contracts_Template');
|
||||
templatQuery.equalTo('CreatedBy', {
|
||||
@@ -13,11 +17,20 @@ async function GetPublicTemplate(request) {
|
||||
className: '_User',
|
||||
objectId: userId,
|
||||
});
|
||||
templatQuery.descending('updatedAt');
|
||||
templatQuery.equalTo('IsPublic', true);
|
||||
const getTemplate = await templatQuery.find({ useMasterKey: true });
|
||||
return getTemplate;
|
||||
|
||||
const extend_Res = await Parse.Cloud.run('getUserDetails', {
|
||||
email: user.get('email'),
|
||||
});
|
||||
if (extend_Res) {
|
||||
return { template: getTemplate, user: user, extend_User: extend_Res };
|
||||
} else {
|
||||
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'Template not found');
|
||||
}
|
||||
} else {
|
||||
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'Template not found');
|
||||
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'User does not exist');
|
||||
}
|
||||
} else {
|
||||
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'Please provide required parameters!');
|
||||
|
||||
Reference in New Issue
Block a user