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 @@
...
@@ -119,6 +119,9 @@
},
},
"httpThirdPartyOTPApiError"
:
{
"httpThirdPartyOTPApiError"
:
{
"type"
:
"boolean"
"type"
:
"boolean"
},
"token"
:
{
"type"
:
"text"
}
}
}
}
}
}
src/extensions/users-permissions/strapi-server.js
View file @
d821e6c
...
@@ -210,7 +210,7 @@ const userPermissionExtension = (plugin) => {
...
@@ -210,7 +210,7 @@ const userPermissionExtension = (plugin) => {
plugin
.
controllers
.
user
.
finishEndUserOtpLogin
=
async
(
ctx
)
=>
{
plugin
.
controllers
.
user
.
finishEndUserOtpLogin
=
async
(
ctx
)
=>
{
const
{
oneTimePassword
,
emailAddress
,
mobileNumber
}
=
ctx
.
request
.
body
;
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
)
{
if
(
!
oneTimePassword
||
!
mobileNumber
||
!
emailAddress
)
{
throw
new
ValidationError
(
throw
new
ValidationError
(
"Please specify the oneTimePassword, email address and mobile numbers."
"Please specify the oneTimePassword, email address and mobile numbers."
...
@@ -304,29 +304,32 @@ const userPermissionExtension = (plugin) => {
...
@@ -304,29 +304,32 @@ const userPermissionExtension = (plugin) => {
{}
{}
);
);
let
oneTimePassword
;
let
oneTimePassword
;
let
responseBody
;
try
{
try
{
// console.log("entered catch",ctx.request.body);
// console.log("entered catch",ctx.request.body);
const
spertoCPOtpData
=
await
strapi
const
spertoCPOtpData
=
await
strapi
.
service
(
"api::channel-partner.channel-partner"
)
.
service
(
"api::channel-partner.channel-partner"
)
.
getCPDataFromSperto
(
ctx
.
request
.
body
);
.
getCPDataFromSperto
(
ctx
.
request
.
body
);
responseBody
=
spertoCPOtpData
;
// console.log("spertoCPOtpData >>>>>",spertoCPOtpData.headers
);
// console.log("spertoCPOtpData >>>>>", spertoCPOtpData
);
ctx
.
request
.
body
.
httpThirdPartyOTPApiRequestHeaders
=
JSON
.
stringify
(
ctx
.
request
.
body
.
httpThirdPartyOTPApiRequestHeaders
=
JSON
.
stringify
(
spertoCPOtpData
.
headers
spertoCPOtpData
.
headers
);
);
ctx
.
request
.
body
.
token
=
spertoCPOtpData
.
data
.
token
;
ctx
.
request
.
body
.
httpThirdPartyOTPApiRequestMethod
=
spertoCPOtpData
.
config
.
method
;
ctx
.
request
.
body
.
httpThirdPartyOTPApiRequestMethod
=
ctx
.
request
.
body
.
httpThirdPartyOTPApiRequestUrl
=
spertoCPOtpData
.
config
.
url
;
spertoCPOtpData
.
config
.
method
;
ctx
.
request
.
body
.
httpsThirdPartyOTPApiRequestBody
=
spertoCPOtpData
.
config
.
data
;
ctx
.
request
.
body
.
httpThirdPartyOTPApiRequestUrl
=
spertoCPOtpData
.
config
.
url
;
ctx
.
request
.
body
.
httpsThirdPartyOTPApiRequestBody
=
spertoCPOtpData
.
config
.
data
;
ctx
.
request
.
body
.
httpThirdPartyOTPApiResposneBody
=
JSON
.
stringify
(
ctx
.
request
.
body
.
httpThirdPartyOTPApiResposneBody
=
JSON
.
stringify
(
spertoCPOtpData
.
data
spertoCPOtpData
.
data
);
);
ctx
.
request
.
body
.
httpThirdPartyOTPApiError
=
false
;
ctx
.
request
.
body
.
httpThirdPartyOTPApiError
=
false
;
// console.log(">>>>>",ctx.request.body.httpThirdPartyOTPApiError);
// console.log(">>>>>",ctx.request.body.httpThirdPartyOTPApiError);
oneTimePassword
=
spertoCPOtpData
.
data
.
otp
oneTimePassword
=
spertoCPOtpData
.
data
.
otp
;
}
catch
(
error
)
{
}
catch
(
error
)
{
ctx
.
request
.
body
.
data
.
httpThirdPartyOTPApiRequestHeaders
=
JSON
.
stringify
(
ctx
.
request
.
body
.
data
.
httpThirdPartyOTPApiRequestHeaders
=
JSON
.
stringify
(
error
.
config
.
headers
error
.
config
.
headers
...
@@ -334,13 +337,15 @@ const userPermissionExtension = (plugin) => {
...
@@ -334,13 +337,15 @@ const userPermissionExtension = (plugin) => {
ctx
.
request
.
body
.
httpThirdPartyOTPApiRequestMethod
=
error
.
config
.
method
;
ctx
.
request
.
body
.
httpThirdPartyOTPApiRequestMethod
=
error
.
config
.
method
;
ctx
.
request
.
body
.
httpThirdPartyOTPApiRequestUrl
=
error
.
config
.
url
;
ctx
.
request
.
body
.
httpThirdPartyOTPApiRequestUrl
=
error
.
config
.
url
;
ctx
.
request
.
body
.
httpsThirdPartyOTPApiRequestBody
=
error
.
config
.
data
;
ctx
.
request
.
body
.
httpsThirdPartyOTPApiRequestBody
=
error
.
config
.
data
;
ctx
.
request
.
body
.
httpThirdPartyOTPApiResposneBody
=
JSON
.
stringify
(
error
.
message
);
ctx
.
request
.
body
.
httpThirdPartyOTPApiResposneBody
=
JSON
.
stringify
(
ctx
.
request
.
body
.
httpThirdPartyOTPApiError
=
true
;
error
.
message
);
ctx
.
request
.
body
.
httpThirdPartyOTPApiError
=
true
;
}
}
const
emailToSend
=
{
const
emailToSend
=
{
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
}
`
,
...
@@ -417,7 +422,10 @@ const userPermissionExtension = (plugin) => {
...
@@ -417,7 +422,10 @@ const userPermissionExtension = (plugin) => {
await
getService
(
"user"
).
edit
(
user
.
id
,
{
await
getService
(
"user"
).
edit
(
user
.
id
,
{
oneTimePassword
:
`
${
oneTimePassword
}
`
,
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
:
{
data
:
{
// httpRequestIsVerifiedHeaders:
// httpRequestIsVerifiedHeaders:
// ctx.request.body.httpRequestIsVerifiedHeaders,
// ctx.request.body.httpRequestIsVerifiedHeaders,
...
@@ -440,14 +448,22 @@ const userPermissionExtension = (plugin) => {
...
@@ -440,14 +448,22 @@ const userPermissionExtension = (plugin) => {
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
:
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.
// Send an email to the user.
// await strapi.plugin("email").service("email").send(emailToSend);
// await strapi.plugin("email").service("email").send(emailToSend);
// TODO: Send SMS.
// TODO: Send SMS.
console
.
log
(
"responseBody"
,
responseBody
);
ctx
.
send
({
ok
:
true
,
message
:
"otp sent"
});
ctx
.
send
({
ok
:
true
,
message
:
"otp sent"
,
data
:
responseBody
.
data
});
};
};
plugin
.
controllers
.
user
.
finishChannelPartnerOtpLogin
=
async
(
ctx
)
=>
{
plugin
.
controllers
.
user
.
finishChannelPartnerOtpLogin
=
async
(
ctx
)
=>
{
...
@@ -457,7 +473,11 @@ const userPermissionExtension = (plugin) => {
...
@@ -457,7 +473,11 @@ const userPermissionExtension = (plugin) => {
"Please specify the oneTimePassword, maharera number and mobile numbers."
"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.
// 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"
)
...
...
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