Commit 62d620e6 by jay

.

1 parent abbe61dc
......@@ -259,44 +259,44 @@ const userPermissionExtension = (plugin) => {
throw new ValidationError("Please specify the maharera number.");
}
const pluginStore = await strapi.store({
type: "plugin",
name: "users-permissions",
});
const emailSettings = await pluginStore.get({ key: "email" });
// Find the channel partner first.
const channelPartner = await strapi
.query("api::channel-partner.channel-partner")
.findOne({
populate: ["user"],
where: {
reraNumber: mahareraNumber,
},
});
if (!channelPartner) {
throw new ValidationError(
"No channel partner registered with specified maharera number."
);
}
// const pluginStore = await strapi.store({
// type: "plugin",
// name: "users-permissions",
// });
// const emailSettings = await pluginStore.get({ key: "email" });
// // Find the channel partner first.
// const channelPartner = await strapi
// .query("api::channel-partner.channel-partner")
// .findOne({
// populate: ["user"],
// where: {
// reraNumber: mahareraNumber,
// },
// });
// if (!channelPartner) {
// throw new ValidationError(
// "No channel partner registered with specified maharera number."
// );
// }
// // Find the linked user next.
const user = await strapi
.query("plugin::users-permissions.user")
.findOne({ where: { id: channelPartner.user.id } });
// // // Find the linked user next.
// const user = await strapi
// .query("plugin::users-permissions.user")
// .findOne({ where: { id: channelPartner.user.id } });
if (!user || user.blocked) {
throw new ValidationError(
"Unable to resolve user linked to channel partner."
);
}
// if (!user || user.blocked) {
// throw new ValidationError(
// "Unable to resolve user linked to channel partner."
// );
// }
const resetPasswordSettings = _.get(
emailSettings,
"reset_password.options",
{}
);
// const resetPasswordSettings = _.get(
// emailSettings,
// "reset_password.options",
// {}
// );
let oneTimePassword;
let responseBody;
......@@ -340,7 +340,7 @@ const userPermissionExtension = (plugin) => {
oneTimePassword: oneTimePassword,
// to: user.email,
from: `contact@hiranandani.net`,
replyTo: resetPasswordSettings.response_email,
// 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}`,
// 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) => {
ctx.request.body.thirdPartyApiError = true;
}
// 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, {
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,
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,
},
}
);
// 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,
// 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);
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!