Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Jay Mehta
/
strapi-setup-file
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Registry
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit b9e3e076
authored
2023-02-22 16:46:19 +0530
by
jay
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
.
1 parent
2cf9b731
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
151 additions
and
86 deletions
.env.example
src/api/channel-partner/controllers/channel-partner.js
src/api/channel-partner/routes/custom-routes.js
src/api/channel-partner/services/channel-partner.js
src/extensions/users-permissions/strapi-server.js
.env.example
View file @
b9e3e07
...
@@ -17,10 +17,10 @@ SMTP_PORT=2525
...
@@ -17,10 +17,10 @@ SMTP_PORT=2525
SMTP_USERNAME=2b3a6bda8b6889
SMTP_USERNAME=2b3a6bda8b6889
SMTP_PASSWORD=521c5fbdaa4326
SMTP_PASSWORD=521c5fbdaa4326
AWS_ACCESS_KEY_ID=
AWS_ACCESS_KEY_ID=
AKIAWEORL2NILWHOB2OQ
AWS_ACCESS_SECRET=
AWS_ACCESS_SECRET=
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
AWS_REGION=
AWS_REGION=
ap-south-1
AWS_BUCKET=
AWS_BUCKET=
hiranandanioffers
SPERTO_API_KEY= "REALATTE-16072021-HVV14-KKJD4-GTCNJ"
SPERTO_API_KEY= "REALATTE-16072021-HVV14-KKJD4-GTCNJ"
CAMPAIGN_KEY="2022110305181116215817187355647526363aa7bc261a662375614"
CAMPAIGN_KEY="2022110305181116215817187355647526363aa7bc261a662375614"
src/api/channel-partner/controllers/channel-partner.js
View file @
b9e3e07
...
@@ -25,76 +25,126 @@ module.exports = createCoreController(
...
@@ -25,76 +25,126 @@ module.exports = createCoreController(
filters
:
{
reraNumber
:
reraNumber
},
filters
:
{
reraNumber
:
reraNumber
},
}
}
);
);
if
(
existingChannelPartner
&&
existingChannelPartner
.
length
!==
0
)
{
// if (existingChannelPartner && existingChannelPartner.length !== 0) {
return
ctx
.
badRequest
(
// return ctx.badRequest(
`Channel Partner Already Exist with the Given rera number
${
reraNumber
}
`
// `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
{
try
{
const
spertoRegisterCP
=
await
strapi
const
spertoRegisterCP
=
await
strapi
.
service
(
"api::channel-partner.channel-partner"
)
.
service
(
"api::channel-partner.channel-partner"
)
.
sendCPToSperto
(
ctx
.
request
.
body
.
data
);
.
sendCPToSperto
(
ctx
.
request
.
body
);
console
.
log
(
"Helllo >>>>>>>>"
,
spertoRegisterCP
);
//
console.log("Helllo >>>>>>>>", spertoRegisterCP);
ctx
.
request
.
body
.
data
.
httpRegisterCPRequestHeaders
=
JSON
.
stringify
(
ctx
.
request
.
body
.
httpRegisterCPRequestHeaders
=
JSON
.
stringify
(
spertoRegisterCP
.
headers
spertoRegisterCP
.
headers
);
);
ctx
.
request
.
body
.
data
.
httpRegisterCPRequestMethod
=
ctx
.
request
.
body
.
httpRegisterCPRequestMethod
=
spertoRegisterCP
.
config
.
method
;
spertoRegisterCP
.
config
.
method
;
ctx
.
request
.
body
.
data
.
httpRegisterCPRequestUrl
=
ctx
.
request
.
body
.
httpRegisterCPRequestUrl
=
spertoRegisterCP
.
config
.
url
;
spertoRegisterCP
.
config
.
url
;
ctx
.
request
.
body
.
httpsRegisterCPRequestBody
=
ctx
.
request
.
body
.
data
.
httpsRegisterCPRequestBody
=
spertoRegisterCP
.
config
.
data
;
spertoRegisterCP
.
config
.
data
;
ctx
.
request
.
body
.
data
.
httpRegisterCPResposneBody
=
JSON
.
stringify
(
ctx
.
request
.
body
.
httpRegisterCPResposneBody
=
JSON
.
stringify
(
spertoRegisterCP
.
data
spertoRegisterCP
.
data
);
);
ctx
.
request
.
body
.
data
.
thirdPartyApiRegisterCPError
=
false
;
ctx
.
request
.
body
.
thirdPartyApiRegisterCPError
=
false
;
}
catch
(
error
)
{
}
catch
(
error
)
{
ctx
.
request
.
body
.
data
.
httpRegisterCPRequestHeaders
=
JSON
.
stringify
(
ctx
.
request
.
body
.
httpRegisterCPRequestHeaders
=
JSON
.
stringify
(
error
.
config
.
headers
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
.
httpRegisterCPRequestUrl
=
error
.
config
.
url
;
ctx
.
request
.
body
.
data
.
httpsRegisterCPRequestBody
=
error
.
config
.
data
;
ctx
.
request
.
body
.
httpsRegisterCPRequestBody
=
error
.
config
.
data
;
ctx
.
request
.
body
.
data
.
httpRegisterCPResposneBody
=
JSON
.
stringify
(
error
.
message
);
ctx
.
request
.
body
.
httpRegisterCPResposneBody
=
JSON
.
stringify
(
ctx
.
request
.
body
.
data
.
thirdPartyApiRegisterCPError
=
true
;
error
.
message
);
ctx
.
request
.
body
.
thirdPartyApiRegisterCPError
=
true
;
}
}
// try {
// const existingChannelPartner = await strapi.entityService.findOne(
// const spertoCPOtp = await strapi.service
// "api::channel-partner.channel-partner",
// .service("api::channel-partner.channel-partner")
// where: {
// .getCPDataFromSperto(ctx.request.body.data);
// 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
,
// }
httpsRegisterCPRequestBody
:
// try {
ctx
.
request
.
body
.
httpsRegisterCPRequestBody
,
// const spertoCPData = await strapi
// .service("api::channel-partner.channel-partner")
// .getCPDataFromSperto(ctx.request.body.data);
// ctx.request.body.data.httpThirdPartyOTPApiRequestHeaders = JSON.stringify(
httpRegisterCPResposneBody
:
// spertoCPData.headers
ctx
.
request
.
body
.
httpRegisterCPResposneBody
,
// );
thirdPartyApiRegisterCPError
:
// ctx.request.body.data.httpThirdPartyOTPApiRequestMethod = spertoCPData.config.method;
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
);
},
},
})
})
);
);
src/api/channel-partner/routes/custom-routes.js
0 → 100644
View file @
b9e3e07
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
;
src/api/channel-partner/services/channel-partner.js
View file @
b9e3e07
...
@@ -13,7 +13,7 @@ module.exports = createCoreService(
...
@@ -13,7 +13,7 @@ module.exports = createCoreService(
"api::channel-partner.channel-partner"
,
"api::channel-partner.channel-partner"
,
({
strapi
:
Strapi
})
=>
({
({
strapi
:
Strapi
})
=>
({
async
sendCPToSperto
(
data
)
{
async
sendCPToSperto
(
data
)
{
console
.
log
(
data
);
//
console.log(data);
const
headers
=
{
"Content-Type"
:
"application/json"
};
const
headers
=
{
"Content-Type"
:
"application/json"
};
const
cpData
=
{
const
cpData
=
{
api_key
:
process
.
env
.
SPERTO_API_KEY
,
api_key
:
process
.
env
.
SPERTO_API_KEY
,
...
@@ -44,7 +44,7 @@ module.exports = createCoreService(
...
@@ -44,7 +44,7 @@ module.exports = createCoreService(
return
spertoResponse
;
return
spertoResponse
;
},
},
async
getCPDataFromSperto
(
data
)
{
async
getCPDataFromSperto
(
data
)
{
console
.
log
(
data
);
//
console.log(data);
const
headers
=
{
"Content-Type"
:
"application/json"
};
const
headers
=
{
"Content-Type"
:
"application/json"
};
const
cpData
=
{
const
cpData
=
{
api_key
:
process
.
env
.
SPERTO_API_KEY
,
api_key
:
process
.
env
.
SPERTO_API_KEY
,
...
...
src/extensions/users-permissions/strapi-server.js
View file @
b9e3e07
...
@@ -554,16 +554,16 @@ const userPermissionExtension = (plugin) => {
...
@@ -554,16 +554,16 @@ const userPermissionExtension = (plugin) => {
if
(
!
role
)
{
if
(
!
role
)
{
throw
new
ApplicationError
(
"Impossible to find the default role"
);
throw
new
ApplicationError
(
"Impossible to find the default role"
);
}
}
console
.
log
(
"HERE ARE PARAMS >>>>>"
,
params
);
// @ts-ignore
// @ts-ignore
const
{
email
,
username
,
provider
}
=
params
;
const
{
email
,
username
,
provider
}
=
params
;
const
identifierFilter
=
{
const
identifierFilter
=
{
$or
:
[
$or
:
[
{
email
:
email
.
toLowerCase
()
},
//
{ email: email.toLowerCase() },
{
username
:
email
.
toLowerCase
()
},
//
{ username: email.toLowerCase() },
{
username
},
{
username
},
{
email
:
username
},
//
{ email: username },
],
],
};
};
...
@@ -573,21 +573,21 @@ const userPermissionExtension = (plugin) => {
...
@@ -573,21 +573,21 @@ const userPermissionExtension = (plugin) => {
where
:
{
...
identifierFilter
,
provider
},
where
:
{
...
identifierFilter
,
provider
},
});
});
//
if (conflictingUserCount > 0) {
if
(
conflictingUserCount
>
0
)
{
// throw new ApplicationError("Email or Username are already taken
");
throw
new
ApplicationError
(
"RERA Number already in use.
"
);
//
}
}
if
(
settings
.
unique_email
)
{
//
if (settings.unique_email) {
const
conflictingUserCount
=
await
strapi
//
const conflictingUserCount = await strapi
.
query
(
"plugin::users-permissions.user"
)
//
.query("plugin::users-permissions.user")
.
count
({
//
.count({
where
:
{
...
identifierFilter
},
//
where: { ...identifierFilter },
});
//
});
// if (conflictingUserCount > 0) {
// if (conflictingUserCount > 0) {
// throw new ApplicationError("Email or Username are already taken");
// throw new ApplicationError("Email or Username are already taken");
// }
// }
}
//
}
let
newUser
=
{
let
newUser
=
{
...
params
,
...
params
,
...
@@ -596,32 +596,32 @@ const userPermissionExtension = (plugin) => {
...
@@ -596,32 +596,32 @@ const userPermissionExtension = (plugin) => {
username
,
username
,
confirmed
:
!
settings
.
email_confirmation
,
confirmed
:
!
settings
.
email_confirmation
,
};
};
console
.
log
(
"newUser 123456789>>>>>"
,
newUser
);
const
user
=
await
strapi
const
user
=
await
strapi
.
plugin
(
"users-permissions"
)
.
plugin
(
"users-permissions"
)
.
service
(
"user"
)
.
service
(
"user"
)
.
add
(
newUser
);
.
add
(
newUser
);
const
sanitizedUser
=
await
sanitizeUser
(
user
,
ctx
);
const
sanitizedUser
=
await
sanitizeUser
(
user
,
ctx
);
console
.
log
(
"SANITIZE sanitizedUser"
,
sanitizedUser
);
if
(
settings
.
email_confirmation
)
{
try
{
// if (settings.email_confirmation)
{
await
strapi
// try {
.
plugin
(
"users-permissions"
)
// await strapi
.
service
(
"user
"
)
// .plugin("users-permissions
")
.
sendConfirmationEmail
(
sanitizedUser
);
// .service("user")
}
catch
(
err
)
{
// .sendConfirmationEmail(sanitizedUser);
throw
new
ApplicationError
(
err
.
message
);
// } catch (err) {
}
// throw new ApplicationError(err.message);
// }
return
ctx
.
send
({
user
:
sanitizedUser
});
//
return ctx.send({ user: sanitizedUser });
}
//
}
const
jwt
=
strapi
const
jwt
=
strapi
.
plugin
(
"users-permissions"
)
.
plugin
(
"users-permissions"
)
.
service
(
"jwt"
)
.
service
(
"jwt"
)
.
issue
(
_
.
pick
(
user
,
[
"id"
]));
.
issue
(
_
.
pick
(
user
,
[
"id"
]));
console
.
log
(
"jwt"
);
return
ctx
.
send
({
return
ctx
.
send
({
jwt
,
jwt
,
user
:
sanitizedUser
,
user
:
sanitizedUser
,
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment