Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Jay Mehta
/
zango-strapi
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 3e22dd36
authored
2024-05-10 16:33:49 +0530
by
jaymehta
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
otp for gift card
1 parent
6662bada
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
15 deletions
src/api/end-user/controllers/end-user.js
src/api/end-user/routes/custom-routes.js
src/api/end-user/controllers/end-user.js
View file @
3e22dd3
...
@@ -26,17 +26,23 @@ module.exports = createCoreController("api::end-user.end-user", () => ({
...
@@ -26,17 +26,23 @@ module.exports = createCoreController("api::end-user.end-user", () => ({
ctx
.
request
.
body
.
data
.
email
ctx
.
request
.
body
.
data
.
email
);
);
let
existingUser
;
let
existingUser
;
existingUser
=
await
strapi
.
entityService
.
findMany
(
"api::end-user.end-user"
,
{
existingUser
=
await
strapi
.
entityService
.
findMany
(
// fields: ["id"],
"api::end-user.end-user"
,
filters
:
{
phone
:
{
$eq
:
ctx
.
request
.
body
.
data
.
mobileNo
}
},
{
});
// fields: ["id"],
filters
:
{
phone
:
{
$eq
:
ctx
.
request
.
body
.
data
.
mobileNo
}
},
}
);
console
.
log
(
"existingUser> 1"
,
existingUser
);
console
.
log
(
"existingUser> 1"
,
existingUser
);
if
(
!
existingUser
)
{
if
(
!
existingUser
)
{
existingUser
=
await
strapi
.
entityService
.
findMany
(
"api::end-user.end-user"
,
{
existingUser
=
await
strapi
.
entityService
.
findMany
(
// fields: ["id"],
"api::end-user.end-user"
,
filters
:
{
email
:
{
$eq
:
ctx
.
request
.
body
.
data
.
email
}
},
{
});
// fields: ["id"],
filters
:
{
email
:
{
$eq
:
ctx
.
request
.
body
.
data
.
email
}
},
}
);
}
}
console
.
log
(
"existingUser > 2"
,
existingUser
);
console
.
log
(
"existingUser > 2"
,
existingUser
);
...
@@ -61,13 +67,16 @@ module.exports = createCoreController("api::end-user.end-user", () => ({
...
@@ -61,13 +67,16 @@ module.exports = createCoreController("api::end-user.end-user", () => ({
if
(
existingUser
&&
existingUser
.
length
!==
0
)
{
if
(
existingUser
&&
existingUser
.
length
!==
0
)
{
}
else
{
}
else
{
ctx
.
request
.
body
.
data
.
user
=
currentUser
.
id
;
ctx
.
request
.
body
.
data
.
user
=
currentUser
.
id
;
const
response
=
await
strapi
.
entityService
.
create
(
"api::end-user.end-user"
,
{
const
response
=
await
strapi
.
entityService
.
create
(
data
:
{
"api::end-user.end-user"
,
...
ctx
.
request
.
body
.
data
,
{
phone
:
ctx
.
request
.
body
.
data
.
mobileNo
,
data
:
{
publishedAt
:
date
,
...
ctx
.
request
.
body
.
data
,
},
phone
:
ctx
.
request
.
body
.
data
.
mobileNo
,
});
publishedAt
:
date
,
},
}
);
console
.
log
(
"response"
,
response
);
console
.
log
(
"response"
,
response
);
return
{
otpSent
:
true
,
data
:
response
};
return
{
otpSent
:
true
,
data
:
response
};
...
@@ -82,4 +91,24 @@ module.exports = createCoreController("api::end-user.end-user", () => ({
...
@@ -82,4 +91,24 @@ module.exports = createCoreController("api::end-user.end-user", () => ({
});
});
},
},
async
giftCardOtp
(
ctx
)
{
// Generate one time password (otp)
// console.log(ctx.request.body);
const
oneTimePassword
=
Math
.
floor
(
1000
+
Math
.
random
()
*
9000
);
const
res
=
await
strapi
.
entityService
.
update
(
"plugin::users-permissions.user"
,
ctx
.
request
.
body
.
data
.
userId
,
{
data
:
{
oneTimePassword
:
`
${
oneTimePassword
}
`
,
},
}
);
// console.log("res", res);
// TODO: ADD FUNCTIONALITY FOR EMAIL AND SMS
ctx
.
send
({
ok
:
true
,
message
:
"OTP sent successfully"
,
});
},
}));
}));
src/api/end-user/routes/custom-routes.js
0 → 100644
View file @
3e22dd3
const
routes
=
{
routes
:
[
{
method
:
"POST"
,
path
:
"/end-user/verify-gift-card-otp"
,
handler
:
"api::end-user.end-user.giftCardOtp"
,
config
:
{
// some configuration...
}
},
]
};
module
.
exports
=
routes
;
\ No newline at end of file
\ No newline at end of file
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