Commit 62d620e6 by jay

.

1 parent abbe61dc
...@@ -259,44 +259,44 @@ const userPermissionExtension = (plugin) => { ...@@ -259,44 +259,44 @@ const userPermissionExtension = (plugin) => {
throw new ValidationError("Please specify the maharera number."); throw new ValidationError("Please specify the maharera number.");
} }
const pluginStore = await strapi.store({ // const pluginStore = await strapi.store({
type: "plugin", // type: "plugin",
name: "users-permissions", // name: "users-permissions",
}); // });
const emailSettings = await pluginStore.get({ key: "email" }); // const emailSettings = await pluginStore.get({ key: "email" });
// Find the channel partner first. // // Find the channel partner first.
const channelPartner = await strapi // const channelPartner = await strapi
.query("api::channel-partner.channel-partner") // .query("api::channel-partner.channel-partner")
.findOne({ // .findOne({
populate: ["user"], // populate: ["user"],
where: { // where: {
reraNumber: mahareraNumber, // reraNumber: mahareraNumber,
}, // },
}); // });
if (!channelPartner) { // if (!channelPartner) {
throw new ValidationError( // throw new ValidationError(
"No channel partner registered with specified maharera number." // "No channel partner registered with specified maharera number."
); // );
} // }
// // Find the linked user next. // // // Find the linked user next.
const user = await strapi // const user = await strapi
.query("plugin::users-permissions.user") // .query("plugin::users-permissions.user")
.findOne({ where: { id: channelPartner.user.id } }); // .findOne({ where: { id: channelPartner.user.id } });
if (!user || user.blocked) { // if (!user || user.blocked) {
throw new ValidationError( // throw new ValidationError(
"Unable to resolve user linked to channel partner." // "Unable to resolve user linked to channel partner."
); // );
} // }
const resetPasswordSettings = _.get( // const resetPasswordSettings = _.get(
emailSettings, // emailSettings,
"reset_password.options", // "reset_password.options",
{} // {}
); // );
let oneTimePassword; let oneTimePassword;
let responseBody; let responseBody;
...@@ -340,7 +340,7 @@ const userPermissionExtension = (plugin) => { ...@@ -340,7 +340,7 @@ const userPermissionExtension = (plugin) => {
oneTimePassword: oneTimePassword, oneTimePassword: oneTimePassword,
// to: user.email, // to: user.email,
from: `contact@hiranandani.net`, from: `contact@hiranandani.net`,
replyTo: resetPasswordSettings.response_email, // replyTo: resetPasswordSettings.response_email,
subject: `Your one time password is: ${oneTimePassword}`, subject: `Your one time password is: ${oneTimePassword}`,
// text: `Hello ${channelPartner.contactPersonName}, Your one time password to login to your partner portal is ${oneTimePassword}`, // text: `Hello ${channelPartner.contactPersonName}, Your one time password to login to your partner portal is ${oneTimePassword}`,
// html: `<p>Hello ${channelPartner.contactPersonName}, <br></br>Your one time password to login to your partner portal is ${oneTimePassword}</p><br /> Best Regards, <br /> Team Hiranandani.`, // html: `<p>Hello ${channelPartner.contactPersonName}, <br></br>Your one time password to login to your partner portal is ${oneTimePassword}</p><br /> Best Regards, <br /> Team Hiranandani.`,
...@@ -413,50 +413,50 @@ const userPermissionExtension = (plugin) => { ...@@ -413,50 +413,50 @@ const userPermissionExtension = (plugin) => {
ctx.request.body.thirdPartyApiError = true; ctx.request.body.thirdPartyApiError = true;
} }
// NOTE: Update the user before sending the email so an Admin can generate the link if the email fails // NOTE: Update the user before sending the email so an Admin can generate the link if the email fails
await getService("user").edit(user.id, { // await getService("user").edit(user.id, {
oneTimePassword: `${oneTimePassword}`, // oneTimePassword: `${oneTimePassword}`,
}); // });
await strapi.entityService.update( // await strapi.entityService.update(
"api::channel-partner.channel-partner", // "api::channel-partner.channel-partner",
channelPartner.id, // channelPartner.id,
{ // {
data: { // data: {
// httpRequestIsVerifiedHeaders: // // httpRequestIsVerifiedHeaders:
// ctx.request.body.httpRequestIsVerifiedHeaders, // // ctx.request.body.httpRequestIsVerifiedHeaders,
// httpsRequestIsVerifiedBody: ctx.request.body.httpsRequestIsVerifiedBody, // // httpsRequestIsVerifiedBody: ctx.request.body.httpsRequestIsVerifiedBody,
// httpRequestIsVerifiedUrl: ctx.request.body.httpRequestIsVerifiedUrl, // // httpRequestIsVerifiedUrl: ctx.request.body.httpRequestIsVerifiedUrl,
// httpRequestIsVerifiedMethod: // // httpRequestIsVerifiedMethod:
// ctx.request.body.httpRequestIsVerifiedMethod, // // ctx.request.body.httpRequestIsVerifiedMethod,
// httpResposneIsVerifiedBody: ctx.request.body.httpResposneIsVerifiedBody, // // httpResposneIsVerifiedBody: ctx.request.body.httpResposneIsVerifiedBody,
// httpRequestIsVerifiedHeaders: // // httpRequestIsVerifiedHeaders:
// ctx.request.body.httpRequestIsVerifiedHeaders, // // ctx.request.body.httpRequestIsVerifiedHeaders,
// httpsRequestIsVerifiedBody: ctx.request.body.httpsRequestIsVerifiedBody, // // httpsRequestIsVerifiedBody: ctx.request.body.httpsRequestIsVerifiedBody,
httpSMSRequestUrl: ctx.request.body.httpSMSRequestUrl, // httpSMSRequestUrl: ctx.request.body.httpSMSRequestUrl,
httpSMSRequestMethod: ctx.request.body.httpSMSRequestMethod, // httpSMSRequestMethod: ctx.request.body.httpSMSRequestMethod,
httpSMSResposneBody: ctx.request.body.httpSMSResposneBody, // httpSMSResposneBody: ctx.request.body.httpSMSResposneBody,
httpSMSRequestHeaders: ctx.request.body.httpSMSRequestHeaders, // httpSMSRequestHeaders: ctx.request.body.httpSMSRequestHeaders,
httpsEmailRequestBody: ctx.request.body.httpsEmailRequestBody, // httpsEmailRequestBody: ctx.request.body.httpsEmailRequestBody,
httpEmailRequestUrl: ctx.request.body.httpEmailRequestUrl, // httpEmailRequestUrl: ctx.request.body.httpEmailRequestUrl,
httpEmailRequestMethod: ctx.request.body.httpEmailRequestMethod, // httpEmailRequestMethod: ctx.request.body.httpEmailRequestMethod,
httpEmailResposneBody: ctx.request.body.httpEmailResposneBody, // httpEmailResposneBody: ctx.request.body.httpEmailResposneBody,
httpEmailRequestHeaders: ctx.request.body.httpEmailRequestHeaders, // httpEmailRequestHeaders: ctx.request.body.httpEmailRequestHeaders,
httpThirdPartyOTPApiRequestHeaders: // httpThirdPartyOTPApiRequestHeaders:
ctx.request.body.httpThirdPartyOTPApiRequestHeaders, // ctx.request.body.httpThirdPartyOTPApiRequestHeaders,
token: ctx.request.body.token, // token: ctx.request.body.token,
httpThirdPartyOTPApiRequestMethod: // httpThirdPartyOTPApiRequestMethod:
ctx.request.body.httpThirdPartyOTPApiRequestMethod, // ctx.request.body.httpThirdPartyOTPApiRequestMethod,
httpThirdPartyOTPApiRequestUrl: // httpThirdPartyOTPApiRequestUrl:
ctx.request.body.httpThirdPartyOTPApiRequestUrl, // ctx.request.body.httpThirdPartyOTPApiRequestUrl,
httpsThirdPartyOTPApiRequestBody: // httpsThirdPartyOTPApiRequestBody:
ctx.request.body.httpsThirdPartyOTPApiRequestBody, // ctx.request.body.httpsThirdPartyOTPApiRequestBody,
httpThirdPartyOTPApiResposneBody: // httpThirdPartyOTPApiResposneBody:
ctx.request.body.httpThirdPartyOTPApiResposneBody, // ctx.request.body.httpThirdPartyOTPApiResposneBody,
}, // },
} // }
); // );
// Send an email to the user. // Send an email to the user.
// await strapi.plugin("email").service("email").send(emailToSend); // await strapi.plugin("email").service("email").send(emailToSend);
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!