Commit b9e3e076 by jay

.

1 parent 2cf9b731
......@@ -17,10 +17,10 @@ SMTP_PORT=2525
SMTP_USERNAME=2b3a6bda8b6889
SMTP_PASSWORD=521c5fbdaa4326
AWS_ACCESS_KEY_ID=
AWS_ACCESS_SECRET=
AWS_REGION=
AWS_BUCKET=
AWS_ACCESS_KEY_ID=AKIAWEORL2NILWHOB2OQ
AWS_ACCESS_SECRET=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
AWS_REGION=ap-south-1
AWS_BUCKET=hiranandanioffers
SPERTO_API_KEY= "REALATTE-16072021-HVV14-KKJD4-GTCNJ"
CAMPAIGN_KEY="2022110305181116215817187355647526363aa7bc261a662375614"
......@@ -25,76 +25,126 @@ module.exports = createCoreController(
filters: { reraNumber: reraNumber },
}
);
if (existingChannelPartner && existingChannelPartner.length !== 0) {
return ctx.badRequest(
`Channel Partner Already Exist with the Given rera number ${reraNumber}`
);
}
// if (existingChannelPartner && existingChannelPartner.length !== 0) {
// return ctx.badRequest(
// `Channel Partner Already Exist with the Given rera number ${reraNumber}`
// );
// }
// try {
// const spertoRegisterCP = await strapi
// .service("api::channel-partner.channel-partner")
// .sendCPToSperto(ctx.request.body.data);
// console.log("Helllo >>>>>>>>", spertoRegisterCP);
// ctx.request.body.data.httpRegisterCPRequestHeaders = JSON.stringify(
// spertoRegisterCP.headers
// );
// ctx.request.body.data.httpRegisterCPRequestMethod =
// spertoRegisterCP.config.method;
// ctx.request.body.data.httpRegisterCPRequestUrl =
// spertoRegisterCP.config.url;
// ctx.request.body.data.httpsRegisterCPRequestBody =
// spertoRegisterCP.config.data;
// ctx.request.body.data.httpRegisterCPResposneBody = JSON.stringify(
// spertoRegisterCP.data
// );
// ctx.request.body.data.thirdPartyApiRegisterCPError = false;
// } catch (error) {
// ctx.request.body.data.httpRegisterCPRequestHeaders = JSON.stringify(
// error.config.headers
// );
// ctx.request.body.data.httpRegisterCPRequestMethod = error.config.method;
// ctx.request.body.data.httpRegisterCPRequestUrl = error.config.url;
// ctx.request.body.data.httpsRegisterCPRequestBody = error.config.data;
// ctx.request.body.data.httpRegisterCPResposneBody = JSON.stringify(error.message);
// ctx.request.body.data.thirdPartyApiRegisterCPError=true;
// }
return await super.create(ctx);
},
async regsiterCPToSperto(ctx) {
// console.log(ctx);
// const currentChannelPartner = ctx.state.user;
const reraNumber = ctx.request.body.reraNumber;
// console.log(reraNumber);
// if (existingChannelPartner && existingChannelPartner.length !== 0) {
// return ctx.badRequest(
// `Channel Partner Already Exist with the Given rera number ${reraNumber}`
// );
// }
try {
const spertoRegisterCP = await strapi
.service("api::channel-partner.channel-partner")
.sendCPToSperto(ctx.request.body.data);
console.log("Helllo >>>>>>>>", spertoRegisterCP);
.sendCPToSperto(ctx.request.body);
// console.log("Helllo >>>>>>>>", spertoRegisterCP);
ctx.request.body.data.httpRegisterCPRequestHeaders = JSON.stringify(
ctx.request.body.httpRegisterCPRequestHeaders = JSON.stringify(
spertoRegisterCP.headers
);
ctx.request.body.data.httpRegisterCPRequestMethod =
ctx.request.body.httpRegisterCPRequestMethod =
spertoRegisterCP.config.method;
ctx.request.body.data.httpRegisterCPRequestUrl =
spertoRegisterCP.config.url;
ctx.request.body.data.httpsRegisterCPRequestBody =
ctx.request.body.httpRegisterCPRequestUrl = spertoRegisterCP.config.url;
ctx.request.body.httpsRegisterCPRequestBody =
spertoRegisterCP.config.data;
ctx.request.body.data.httpRegisterCPResposneBody = JSON.stringify(
ctx.request.body.httpRegisterCPResposneBody = JSON.stringify(
spertoRegisterCP.data
);
ctx.request.body.data.thirdPartyApiRegisterCPError = false;
ctx.request.body.thirdPartyApiRegisterCPError = false;
} catch (error) {
ctx.request.body.data.httpRegisterCPRequestHeaders = JSON.stringify(
ctx.request.body.httpRegisterCPRequestHeaders = JSON.stringify(
error.config.headers
);
ctx.request.body.data.httpRegisterCPRequestMethod = error.config.method;
ctx.request.body.httpRegisterCPRequestMethod = error.config.method;
ctx.request.body.data.httpRegisterCPRequestUrl = error.config.url;
ctx.request.body.data.httpsRegisterCPRequestBody = error.config.data;
ctx.request.body.data.httpRegisterCPResposneBody = JSON.stringify(error.message);
ctx.request.body.data.thirdPartyApiRegisterCPError=true;
ctx.request.body.httpRegisterCPRequestUrl = error.config.url;
ctx.request.body.httpsRegisterCPRequestBody = error.config.data;
ctx.request.body.httpRegisterCPResposneBody = JSON.stringify(
error.message
);
ctx.request.body.thirdPartyApiRegisterCPError = true;
}
// try {
// const spertoCPOtp = await strapi.service
// .service("api::channel-partner.channel-partner")
// .getCPDataFromSperto(ctx.request.body.data);
// const existingChannelPartner = await strapi.entityService.findOne(
// "api::channel-partner.channel-partner",
// where: {
// reraNumber: reraNumber
// }
// );
const existingChannelPartner = await strapi
.query("api::channel-partner.channel-partner")
.findOne({
// populate: ["id"],
where: {
$and: [{ reraNumber: reraNumber }],
},
});
console.log("existingChannelPartner >>>>>>>>>>", existingChannelPartner);
const res = await strapi.entityService.update(
"api::channel-partner.channel-partner",
existingChannelPartner.id,
{
data: {
httpRegisterCPRequestHeaders:
ctx.request.body.httpRegisterCPRequestHeaders,
httpRegisterCPRequestMethod:
ctx.request.body.httpRegisterCPRequestMethod,
// } catch (error) {
httpRegisterCPRequestUrl: ctx.request.body.httpRegisterCPRequestUrl,
// }
// try {
// const spertoCPData = await strapi
// .service("api::channel-partner.channel-partner")
// .getCPDataFromSperto(ctx.request.body.data);
httpsRegisterCPRequestBody:
ctx.request.body.httpsRegisterCPRequestBody,
// ctx.request.body.data.httpThirdPartyOTPApiRequestHeaders = JSON.stringify(
// spertoCPData.headers
// );
// ctx.request.body.data.httpThirdPartyOTPApiRequestMethod = spertoCPData.config.method;
httpRegisterCPResposneBody:
ctx.request.body.httpRegisterCPResposneBody,
thirdPartyApiRegisterCPError:
ctx.request.body.thirdPartyApiRegisterCPError,
},
}
);
console.log("res >>>>>",res);
ctx.send({ ok: true, data: res});
// ctx.request.body.data.httpThirdPartyOTPApiRequestUrl = spertoCPData.config.url;
// ctx.request.body.data.httpsThirdPartyOTPApiRequestBody = spertoCPData.config.data;
// ctx.request.body.data.httpThirdPartyOTPApiResposneBody = JSON.stringify(
// spertoCPData.data
// );
// ctx.request.body.data.thirdThirdPartyOTPApiPartyApiError=false;
// } catch (error) {
// ctx.request.body.data.httpThirdPartyOTPApiRequestHeaders = JSON.stringify(
// error.config.headers
// );
// ctx.request.body.data.httpThirdPartyOTPApiRequestMethod = error.config.method;
// ctx.request.body.data.httpThirdPartyOTPApiRequestUrl = error.config.url;
// ctx.request.body.data.httpsThirdPartyOTPApiRequestBody = error.config.data;
// ctx.request.body.data.httpThirdPartyOTPApiResposneBody = JSON.stringify(error.message);
// ctx.request.body.data.thirdThirdPartyOTPApiPartyApiError=true;
// }
return await super.create(ctx);
},
})
);
const routes = {
routes: [
{
method: "POST",
path: "/channel-partner/register-cp-to-sperto",
handler: "api::channel-partner.channel-partner.regsiterCPToSperto",
config: {
// some configuration...
}
},
]
};
module.exports = routes;
......@@ -13,7 +13,7 @@ module.exports = createCoreService(
"api::channel-partner.channel-partner",
({ strapi: Strapi }) => ({
async sendCPToSperto(data) {
console.log(data);
// console.log(data);
const headers = { "Content-Type": "application/json" };
const cpData = {
api_key: process.env.SPERTO_API_KEY,
......@@ -44,7 +44,7 @@ module.exports = createCoreService(
return spertoResponse;
},
async getCPDataFromSperto(data) {
console.log(data);
// console.log(data);
const headers = { "Content-Type": "application/json" };
const cpData = {
api_key: process.env.SPERTO_API_KEY,
......
......@@ -554,16 +554,16 @@ const userPermissionExtension = (plugin) => {
if (!role) {
throw new ApplicationError("Impossible to find the default role");
}
console.log("HERE ARE PARAMS >>>>>", params);
// @ts-ignore
const { email, username, provider } = params;
const identifierFilter = {
$or: [
{ email: email.toLowerCase() },
{ username: email.toLowerCase() },
// { email: email.toLowerCase() },
// { username: email.toLowerCase() },
{ username },
{ email: username },
// { email: username },
],
};
......@@ -573,21 +573,21 @@ const userPermissionExtension = (plugin) => {
where: { ...identifierFilter, provider },
});
// if (conflictingUserCount > 0) {
// throw new ApplicationError("Email or Username are already taken");
// }
if (conflictingUserCount > 0) {
throw new ApplicationError("RERA Number already in use.");
}
if (settings.unique_email) {
const conflictingUserCount = await strapi
.query("plugin::users-permissions.user")
.count({
where: { ...identifierFilter },
});
// if (settings.unique_email) {
// const conflictingUserCount = await strapi
// .query("plugin::users-permissions.user")
// .count({
// where: { ...identifierFilter },
// });
// if (conflictingUserCount > 0) {
// throw new ApplicationError("Email or Username are already taken");
// }
}
// }
let newUser = {
...params,
......@@ -596,32 +596,32 @@ const userPermissionExtension = (plugin) => {
username,
confirmed: !settings.email_confirmation,
};
console.log("newUser 123456789>>>>>", newUser);
const user = await strapi
.plugin("users-permissions")
.service("user")
.add(newUser);
const sanitizedUser = await sanitizeUser(user, ctx);
if (settings.email_confirmation) {
try {
await strapi
.plugin("users-permissions")
.service("user")
.sendConfirmationEmail(sanitizedUser);
} catch (err) {
throw new ApplicationError(err.message);
}
return ctx.send({ user: sanitizedUser });
}
console.log("SANITIZE sanitizedUser", sanitizedUser);
// if (settings.email_confirmation) {
// try {
// await strapi
// .plugin("users-permissions")
// .service("user")
// .sendConfirmationEmail(sanitizedUser);
// } catch (err) {
// throw new ApplicationError(err.message);
// }
// return ctx.send({ user: sanitizedUser });
// }
const jwt = strapi
.plugin("users-permissions")
.service("jwt")
.issue(_.pick(user, ["id"]));
console.log("jwt");
return ctx.send({
jwt,
user: sanitizedUser,
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!