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 0d97e40e
authored
2023-02-15 14:57:28 +0530
by
jay
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
.
1 parent
4b59ba54
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
107 additions
and
30 deletions
src/api/channel-partner/content-types/channel-partner/schema.json
src/api/channel-partner/controllers/channel-partner.js
src/api/channel-partner/services/channel-partner.js
src/extensions/users-permissions/content-types/user/schema.json
src/extensions/users-permissions/strapi-server.js
src/api/channel-partner/content-types/channel-partner/schema.json
View file @
0d97e40
...
@@ -104,6 +104,21 @@
...
@@ -104,6 +104,21 @@
},
},
"httpsEmailRequestBody"
:
{
"httpsEmailRequestBody"
:
{
"type"
:
"text"
"type"
:
"text"
},
"httpThirdPartyOTPApiRequestMethod"
:
{
"type"
:
"text"
},
"httpThirdPartyOTPApiRequestUrl"
:
{
"type"
:
"text"
},
"httpsThirdPartyOTPApiRequestBody"
:
{
"type"
:
"text"
},
"httpThirdPartyOTPApiResposneBody"
:
{
"type"
:
"text"
},
"httpThirdPartyOTPApiError"
:
{
"type"
:
"boolean"
}
}
}
}
}
}
src/api/channel-partner/controllers/channel-partner.js
View file @
0d97e40
...
@@ -28,32 +28,40 @@ module.exports = createCoreController(
...
@@ -28,32 +28,40 @@ module.exports = createCoreController(
`Channel Partner Already Exist with the Given rera number
${
reraNumber
}
`
`Channel Partner Already Exist with the Given rera number
${
reraNumber
}
`
);
);
}
}
// try {
// const spertoCPOtp = await strapi.service
// .service("api::channel-partner.channel-partner")
// .getCPDataFromSperto(ctx.request.body.data);
try
{
const
spertoCPData
=
await
strapi
.
service
(
"api::channel-partner.channel-partner"
)
.
sendCPToSperto
(
ctx
.
request
.
body
.
data
);
ctx
.
request
.
body
.
data
.
httpRequestHeaders
=
JSON
.
stringify
(
// } catch (error) {
spertoCPData
.
headers
);
// }
ctx
.
request
.
body
.
data
.
httpRequestMethod
=
spertoCPData
.
config
.
method
;
// try {
ctx
.
request
.
body
.
data
.
httpRequestUrl
=
spertoCPData
.
config
.
url
;
// const spertoCPData = await strapi
ctx
.
request
.
body
.
data
.
httpsRequestBody
=
spertoCPData
.
config
.
data
;
// .service("api::channel-partner.channel-partner")
ctx
.
request
.
body
.
data
.
httpResposneBody
=
JSON
.
stringify
(
// .getCPDataFromSperto(ctx.request.body.data);
spertoCPData
.
data
);
// ctx.request.body.data.httpThirdPartyOTPApiRequestHeaders = JSON.stringify(
ctx
.
request
.
body
.
data
.
thirdPartyApiError
=
false
;
// spertoCPData.headers
}
catch
(
error
)
{
// );
ctx
.
request
.
body
.
data
.
httpRequestHeaders
=
JSON
.
stringify
(
// ctx.request.body.data.httpThirdPartyOTPApiRequestMethod = spertoCPData.config.method;
error
.
config
.
headers
// ctx.request.body.data.httpThirdPartyOTPApiRequestUrl = spertoCPData.config.url;
);
// ctx.request.body.data.httpsThirdPartyOTPApiRequestBody = spertoCPData.config.data;
ctx
.
request
.
body
.
data
.
httpRequestMethod
=
error
.
config
.
method
;
// ctx.request.body.data.httpThirdPartyOTPApiResposneBody = JSON.stringify(
ctx
.
request
.
body
.
data
.
httpRequestUrl
=
error
.
config
.
url
;
// spertoCPData.data
ctx
.
request
.
body
.
data
.
httpsRequestBody
=
error
.
config
.
data
;
// );
ctx
.
request
.
body
.
data
.
httpResposneBody
=
JSON
.
stringify
(
error
.
message
);
// ctx.request.body.data.thirdThirdPartyOTPApiPartyApiError=false;
ctx
.
request
.
body
.
data
.
thirdPartyApiError
=
true
;
// } 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
);
return
await
super
.
create
(
ctx
);
},
},
})
})
...
...
src/api/channel-partner/services/channel-partner.js
View file @
0d97e40
"use strict"
;
"use strict"
;
const
{
default
:
axios
}
=
require
(
"axios"
);
// const { default: axios } = require("axios");
const
axios
=
require
(
"axios"
);
/**
/**
* channel-partner service
* channel-partner service
...
@@ -42,5 +44,24 @@ module.exports = createCoreService(
...
@@ -42,5 +44,24 @@ module.exports = createCoreService(
// console.log("cp response", spertoResponse);
// console.log("cp response", spertoResponse);
return
spertoResponse
;
return
spertoResponse
;
},
},
async
getCPDataFromSperto
(
data
)
{
// console.log(data);
const
headers
=
{
"Content-Type"
:
"application/json"
};
const
cpData
=
{
api_key
:
process
.
env
.
SPERTO_API_KEY
,
// cp_rera_no: "RE12389222"
cp_rera_no
:
data
.
mahareraNumber
// sourcing_manager_id
// gst_certificate_path: data.
};
const
spertoCPOTPResponse
=
await
axios
.
post
(
"https://net4hgc.sperto.co.in/_api/api_auth_cp_login.php"
,
cpData
,
{
headers
:
headers
}
);
// console.log("cp response",spertoCPOTPResponse);
return
spertoCPOTPResponse
;
},
})
})
);
);
src/extensions/users-permissions/content-types/user/schema.json
View file @
0d97e40
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
},
},
"password"
:
{
"password"
:
{
"type"
:
"password"
,
"type"
:
"password"
,
"minLength"
:
6
,
"minLength"
:
1
,
"configurable"
:
false
,
"configurable"
:
false
,
"private"
:
true
"private"
:
true
},
},
...
@@ -65,7 +65,7 @@
...
@@ -65,7 +65,7 @@
},
},
"oneTimePassword"
:
{
"oneTimePassword"
:
{
"type"
:
"string"
,
"type"
:
"string"
,
"configurable"
:
fals
e
,
"configurable"
:
tru
e
,
"private"
:
true
"private"
:
true
},
},
"dialCode"
:
{
"dialCode"
:
{
...
...
src/extensions/users-permissions/strapi-server.js
View file @
0d97e40
...
@@ -210,6 +210,7 @@ const userPermissionExtension = (plugin) => {
...
@@ -210,6 +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
);
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."
...
@@ -302,8 +303,40 @@ const userPermissionExtension = (plugin) => {
...
@@ -302,8 +303,40 @@ const userPermissionExtension = (plugin) => {
"reset_password.options"
,
"reset_password.options"
,
{}
{}
);
);
const
oneTimePassword
=
Math
.
floor
(
100000
+
Math
.
random
()
*
900000
);
let
oneTimePassword
;
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);
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
.
httpThirdPartyOTPApiResposneBody
=
JSON
.
stringify
(
spertoCPOtpData
.
data
);
ctx
.
request
.
body
.
httpThirdPartyOTPApiError
=
false
;
// console.log(">>>>>",ctx.request.body.httpThirdPartyOTPApiError);
oneTimePassword
=
spertoCPOtpData
.
data
.
otp
}
catch
(
error
)
{
ctx
.
request
.
body
.
data
.
httpThirdPartyOTPApiRequestHeaders
=
JSON
.
stringify
(
error
.
config
.
headers
);
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
;
}
const
emailToSend
=
{
const
emailToSend
=
{
oneTimePassword
:
oneTimePassword
,
oneTimePassword
:
oneTimePassword
,
to
:
user
.
email
,
to
:
user
.
email
,
...
@@ -424,7 +457,7 @@ const userPermissionExtension = (plugin) => {
...
@@ -424,7 +457,7 @@ 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
});
// 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"
)
...
@@ -462,7 +495,7 @@ const userPermissionExtension = (plugin) => {
...
@@ -462,7 +495,7 @@ const userPermissionExtension = (plugin) => {
oneTimePassword
:
null
,
oneTimePassword
:
null
,
password
:
oneTimePassword
,
password
:
oneTimePassword
,
});
});
console
.
log
(
"ctx"
);
ctx
.
send
({
ok
:
true
,
message
:
"otp updated"
});
ctx
.
send
({
ok
:
true
,
message
:
"otp updated"
});
};
};
...
...
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