mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-08-21 23:22:35 +02:00
refactor: change variable from isDisableOTP to isEnableOTP
This commit is contained in:
@@ -10,9 +10,9 @@ export default async function callWebhook(request) {
|
||||
try {
|
||||
const docQuery = new Parse.Query('contracts_Document');
|
||||
const docRes = await docQuery.get(docId, { useMasterKey: true });
|
||||
const isDisableOTP = docRes?.get('IsDisableOTP') || false;
|
||||
const isEnableOTP = docRes?.get('IsEnableOTP') || false;
|
||||
let userId;
|
||||
if (!isDisableOTP) {
|
||||
if (!isEnableOTP) {
|
||||
const userRes = await axios.get(serverUrl + '/users/me', {
|
||||
headers: {
|
||||
'X-Parse-Application-Id': appId,
|
||||
@@ -21,7 +21,7 @@ export default async function callWebhook(request) {
|
||||
});
|
||||
userId = userRes.data && userRes.data.objectId;
|
||||
}
|
||||
if (isDisableOTP || userId) {
|
||||
if (!isEnableOTP || userId) {
|
||||
if (event === 'viewed' && contactId) {
|
||||
if (docRes) {
|
||||
const _docRes = docRes.toJSON();
|
||||
|
||||
@@ -199,7 +199,7 @@ export default async function createBatchDocs(request) {
|
||||
TimeToCompleteDays: x.TimeToCompleteDays || 15,
|
||||
OriginIp: Ip,
|
||||
DocSentAt: { __type: 'Date', iso: isoDate },
|
||||
IsDisableOTP: x?.IsDisableOTP || false,
|
||||
IsEnableOTP: x?.IsEnableOTP || false,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
@@ -19,8 +19,8 @@ export default async function getDocument(request) {
|
||||
query.notEqualTo('IsArchive', true);
|
||||
const res = await query.first({ useMasterKey: true });
|
||||
if (res) {
|
||||
const IsDisableOTP = res?.get('IsDisableOTP') || false;
|
||||
if (IsDisableOTP) {
|
||||
const IsEnableOTP = res?.get('IsEnableOTP') || false;
|
||||
if (!IsEnableOTP) {
|
||||
return res;
|
||||
} else {
|
||||
if (request?.headers?.['sessiontoken']) {
|
||||
|
||||
@@ -34,7 +34,7 @@ export async function getSignedUrl(request) {
|
||||
try {
|
||||
const query = new Parse.Query('contracts_Document');
|
||||
query.equalTo('objectId', docId);
|
||||
query.equalTo('IsDisableOTP', true);
|
||||
query.notEqualTo('IsEnableOTP', true);
|
||||
query.include('CreatedBy');
|
||||
query.include('Signers');
|
||||
query.include('AuditTrail.UserPtr');
|
||||
|
||||
@@ -32,7 +32,7 @@ export default async function GenerateCertificate(docDetails) {
|
||||
const OriginIp = docDetails?.OriginIp || '';
|
||||
const company = docDetails?.ExtUserPtr?.Company || '';
|
||||
const createdAt = docDetails?.DocSentAt?.iso || docDetails.createdAt;
|
||||
const isDisableOTP = docDetails?.IsDisableOTP || false;
|
||||
const IsEnableOTP = docDetails?.IsEnableOTP || false;
|
||||
const auditTrail =
|
||||
docDetails?.Signers?.length > 0
|
||||
? docDetails.AuditTrail.map(x => {
|
||||
@@ -349,7 +349,7 @@ export default async function GenerateCertificate(docDetails) {
|
||||
font: timesRomanFont,
|
||||
color: textValueColor,
|
||||
});
|
||||
if (!isDisableOTP) {
|
||||
if (IsEnableOTP) {
|
||||
page.drawText('Security level :', {
|
||||
x: half + 55,
|
||||
y: yPosition4 + 10,
|
||||
|
||||
@@ -286,9 +286,9 @@ async function PDF(req) {
|
||||
if (!resDoc) {
|
||||
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'Document not found.');
|
||||
}
|
||||
const IsDisableOTP = resDoc?.get('IsDisableOTP') || false;
|
||||
// if `IsDisableOTP` is true then we don't have to check authentication
|
||||
if (!IsDisableOTP) {
|
||||
const IsEnableOTP = resDoc?.get('IsEnableOTP') || false;
|
||||
// if `IsEnableOTP` is false then we don't have to check authentication
|
||||
if (IsEnableOTP) {
|
||||
if (!req?.user) {
|
||||
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'User is not authenticated.');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user