Commit d821e6c9 by jay

channel partner

1 parent 81d3858d
......@@ -119,6 +119,9 @@
},
"httpThirdPartyOTPApiError": {
"type": "boolean"
},
"token": {
"type": "text"
}
}
}
......@@ -210,7 +210,7 @@ const userPermissionExtension = (plugin) => {
plugin.controllers.user.finishEndUserOtpLogin = async (ctx) => {
const { oneTimePassword, emailAddress, mobileNumber } = ctx.request.body;
console.log("ctx.request.body",ctx.request.body);
console.log("ctx.request.body", ctx.request.body);
if (!oneTimePassword || !mobileNumber || !emailAddress) {
throw new ValidationError(
"Please specify the oneTimePassword, email address and mobile numbers."
......@@ -304,29 +304,32 @@ const userPermissionExtension = (plugin) => {
{}
);
let oneTimePassword;
let responseBody;
try {
// console.log("entered catch",ctx.request.body);
const spertoCPOtpData = await strapi
.service("api::channel-partner.channel-partner")
.getCPDataFromSperto(ctx.request.body);
// console.log("spertoCPOtpData >>>>>",spertoCPOtpData.headers);
responseBody = spertoCPOtpData;
// console.log("spertoCPOtpData >>>>>", spertoCPOtpData);
ctx.request.body.httpThirdPartyOTPApiRequestHeaders = JSON.stringify(
spertoCPOtpData.headers
);
ctx.request.body.httpThirdPartyOTPApiRequestMethod = spertoCPOtpData.config.method;
ctx.request.body.httpThirdPartyOTPApiRequestUrl = spertoCPOtpData.config.url;
ctx.request.body.httpsThirdPartyOTPApiRequestBody = spertoCPOtpData.config.data;
ctx.request.body.token = spertoCPOtpData.data.token;
ctx.request.body.httpThirdPartyOTPApiRequestMethod =
spertoCPOtpData.config.method;
ctx.request.body.httpThirdPartyOTPApiRequestUrl =
spertoCPOtpData.config.url;
ctx.request.body.httpsThirdPartyOTPApiRequestBody =
spertoCPOtpData.config.data;
ctx.request.body.httpThirdPartyOTPApiResposneBody = JSON.stringify(
spertoCPOtpData.data
);
ctx.request.body.httpThirdPartyOTPApiError=false;
// console.log(">>>>>",ctx.request.body.httpThirdPartyOTPApiError);
oneTimePassword = spertoCPOtpData.data.otp
);
ctx.request.body.httpThirdPartyOTPApiError = false;
// console.log(">>>>>",ctx.request.body.httpThirdPartyOTPApiError);
oneTimePassword = spertoCPOtpData.data.otp;
} catch (error) {
ctx.request.body.data.httpThirdPartyOTPApiRequestHeaders = JSON.stringify(
error.config.headers
......@@ -334,13 +337,15 @@ const userPermissionExtension = (plugin) => {
ctx.request.body.httpThirdPartyOTPApiRequestMethod = error.config.method;
ctx.request.body.httpThirdPartyOTPApiRequestUrl = error.config.url;
ctx.request.body.httpsThirdPartyOTPApiRequestBody = error.config.data;
ctx.request.body.httpThirdPartyOTPApiResposneBody = JSON.stringify(error.message);
ctx.request.body.httpThirdPartyOTPApiError=true;
ctx.request.body.httpThirdPartyOTPApiResposneBody = JSON.stringify(
error.message
);
ctx.request.body.httpThirdPartyOTPApiError = true;
}
const emailToSend = {
oneTimePassword:oneTimePassword,
oneTimePassword: oneTimePassword,
to: user.email,
from:`contact@hiranandani.net`,
from: `contact@hiranandani.net`,
replyTo: resetPasswordSettings.response_email,
subject: `Your one time password is: ${oneTimePassword}`,
text: `Hello ${channelPartner.contactPersonName}, Your one time password to login to your partner portal is ${oneTimePassword}`,
......@@ -417,37 +422,48 @@ const userPermissionExtension = (plugin) => {
await getService("user").edit(user.id, {
oneTimePassword: `${oneTimePassword}`,
});
await strapi.entityService.update("api::channel-partner.channel-partner", channelPartner.id, {
data: {
// httpRequestIsVerifiedHeaders:
// ctx.request.body.httpRequestIsVerifiedHeaders,
// httpsRequestIsVerifiedBody: ctx.request.body.httpsRequestIsVerifiedBody,
// httpRequestIsVerifiedUrl: ctx.request.body.httpRequestIsVerifiedUrl,
// httpRequestIsVerifiedMethod:
// ctx.request.body.httpRequestIsVerifiedMethod,
// httpResposneIsVerifiedBody: ctx.request.body.httpResposneIsVerifiedBody,
// httpRequestIsVerifiedHeaders:
// ctx.request.body.httpRequestIsVerifiedHeaders,
// httpsRequestIsVerifiedBody: ctx.request.body.httpsRequestIsVerifiedBody,
httpSMSRequestUrl: ctx.request.body.httpSMSRequestUrl,
httpSMSRequestMethod: ctx.request.body.httpSMSRequestMethod,
httpSMSResposneBody: ctx.request.body.httpSMSResposneBody,
httpSMSRequestHeaders: ctx.request.body.httpSMSRequestHeaders,
httpsEmailRequestBody: ctx.request.body.httpsEmailRequestBody,
httpEmailRequestUrl: ctx.request.body.httpEmailRequestUrl,
httpEmailRequestMethod: ctx.request.body.httpEmailRequestMethod,
httpEmailResposneBody: ctx.request.body.httpEmailResposneBody,
httpEmailRequestHeaders: ctx.request.body.httpEmailRequestHeaders,
},
});
await strapi.entityService.update(
"api::channel-partner.channel-partner",
channelPartner.id,
{
data: {
// httpRequestIsVerifiedHeaders:
// ctx.request.body.httpRequestIsVerifiedHeaders,
// httpsRequestIsVerifiedBody: ctx.request.body.httpsRequestIsVerifiedBody,
// httpRequestIsVerifiedUrl: ctx.request.body.httpRequestIsVerifiedUrl,
// httpRequestIsVerifiedMethod:
// ctx.request.body.httpRequestIsVerifiedMethod,
// httpResposneIsVerifiedBody: ctx.request.body.httpResposneIsVerifiedBody,
// httpRequestIsVerifiedHeaders:
// ctx.request.body.httpRequestIsVerifiedHeaders,
// httpsRequestIsVerifiedBody: ctx.request.body.httpsRequestIsVerifiedBody,
httpSMSRequestUrl: ctx.request.body.httpSMSRequestUrl,
httpSMSRequestMethod: ctx.request.body.httpSMSRequestMethod,
httpSMSResposneBody: ctx.request.body.httpSMSResposneBody,
httpSMSRequestHeaders: ctx.request.body.httpSMSRequestHeaders,
httpsEmailRequestBody: ctx.request.body.httpsEmailRequestBody,
httpEmailRequestUrl: ctx.request.body.httpEmailRequestUrl,
httpEmailRequestMethod: ctx.request.body.httpEmailRequestMethod,
httpEmailResposneBody: ctx.request.body.httpEmailResposneBody,
httpEmailRequestHeaders: ctx.request.body.httpEmailRequestHeaders,
httpThirdPartyOTPApiRequestHeaders: ctx.request.body.httpThirdPartyOTPApiRequestHeaders,
token: ctx.request.body.token,
httpThirdPartyOTPApiRequestMethod: ctx.request.body.httpThirdPartyOTPApiRequestMethod,
httpThirdPartyOTPApiRequestUrl: ctx.request.body.httpThirdPartyOTPApiRequestUrl,
httpsThirdPartyOTPApiRequestBody: ctx.request.body.httpsThirdPartyOTPApiRequestBody,
httpThirdPartyOTPApiResposneBody: ctx.request.body.httpThirdPartyOTPApiResposneBody
},
}
);
// Send an email to the user.
// await strapi.plugin("email").service("email").send(emailToSend);
// TODO: Send SMS.
ctx.send({ ok: true, message: "otp sent" });
console.log("responseBody", responseBody);
ctx.send({ ok: true, message: "otp sent", data: responseBody.data });
};
plugin.controllers.user.finishChannelPartnerOtpLogin = async (ctx) => {
......@@ -457,7 +473,11 @@ const userPermissionExtension = (plugin) => {
"Please specify the oneTimePassword, maharera number and mobile numbers."
);
}
console.log("{ oneTimePassword, mahareraNumber, mobileNumber }",{ oneTimePassword, mahareraNumber, mobileNumber });
console.log("{ oneTimePassword, mahareraNumber, mobileNumber }", {
oneTimePassword,
mahareraNumber,
mobileNumber,
});
// Find the channel partner first.
const channelPartner = await strapi
.query("api::channel-partner.channel-partner")
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!