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 d821e6c9
authored
2023-02-17 15:12:01 +0530
by
jay
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
channel partner
1 parent
81d3858d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
19 deletions
src/api/channel-partner/content-types/channel-partner/schema.json
src/extensions/users-permissions/strapi-server.js
src/api/channel-partner/content-types/channel-partner/schema.json
View file @
d821e6c
...
...
@@ -119,6 +119,9 @@
},
"httpThirdPartyOTPApiError"
:
{
"type"
:
"boolean"
},
"token"
:
{
"type"
:
"text"
}
}
}
src/extensions/users-permissions/strapi-server.js
View file @
d821e6c
...
...
@@ -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
;
ctx
.
request
.
body
.
httpThirdPartyOTPApiError
=
false
;
// console.log(">>>>>",ctx.request.body.httpThirdPartyOTPApiError);
oneTimePassword
=
spertoCPOtpData
.
data
.
otp
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,7 +422,10 @@ const userPermissionExtension = (plugin) => {
await
getService
(
"user"
).
edit
(
user
.
id
,
{
oneTimePassword
:
`
${
oneTimePassword
}
`
,
});
await
strapi
.
entityService
.
update
(
"api::channel-partner.channel-partner"
,
channelPartner
.
id
,
{
await
strapi
.
entityService
.
update
(
"api::channel-partner.channel-partner"
,
channelPartner
.
id
,
{
data
:
{
// httpRequestIsVerifiedHeaders:
// ctx.request.body.httpRequestIsVerifiedHeaders,
...
...
@@ -440,14 +448,22 @@ const userPermissionExtension = (plugin) => {
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"
)
...
...
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