mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-08-22 15:42:31 +02:00
feat: handle undefine username/password for SMTP
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
export default async function saveSignature(request) {
|
||||
const { signature, userId, initials, id, title } = request.params;
|
||||
|
||||
if (!userId) {
|
||||
throw new Parse.Error(Parse.Error.INVALID_QUERY, 'Missing userId parameter.');
|
||||
}
|
||||
if (userId !== request.user?.id) {
|
||||
throw new Parse.Error(Parse.Error.INVALID_QUERY, 'Cannot save signature for the current user.');
|
||||
}
|
||||
const userPtr = { __type: 'Pointer', className: '_User', objectId: userId };
|
||||
try {
|
||||
const signatureCls = new Parse.Object('contracts_Signature');
|
||||
if (id) {
|
||||
signatureCls.id = id;
|
||||
}
|
||||
if (initials) {
|
||||
signatureCls.set('Initials', initials);
|
||||
}
|
||||
if (signature) {
|
||||
signatureCls.set('ImageURL', signature);
|
||||
}
|
||||
if (title) {
|
||||
signatureCls.set('SignatureName', title);
|
||||
}
|
||||
if (userPtr) {
|
||||
signatureCls.set('UserId', userPtr);
|
||||
}
|
||||
const signRes = await signatureCls.save(null, { useMasterKey: true });
|
||||
return signRes;
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user