summaryrefslogtreecommitdiff
path: root/server/controllers/otp.js
diff options
context:
space:
mode:
authorrohan09-raj <[email protected]>2022-08-19 00:10:29 +0530
committerrohan09-raj <[email protected]>2022-08-19 00:10:42 +0530
commit953dd3c954411d92811415cc9be4a7c7d76ab185 (patch)
tree0bd2aa118361bbe70f0ac0b62da3c12fa1cb902f /server/controllers/otp.js
parenta9ed2c9daa5a3e065401996daf922f59de7f0101 (diff)
added otp support
Diffstat (limited to 'server/controllers/otp.js')
-rw-r--r--server/controllers/otp.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/server/controllers/otp.js b/server/controllers/otp.js
new file mode 100644
index 0000000..5b4bd82
--- /dev/null
+++ b/server/controllers/otp.js
@@ -0,0 +1,17 @@
+import generateOTP from '../utils/otp';
+import sendMessage from '../services/twilio';
+
+const sendOTP = async (req, res) => {
+ const {mobile} = req.body;
+
+ try {
+ const otp = generateOTP();
+ const message = `Your OTP for Aadhaar verification is : ${otp}`;
+ sendMessage(mobile, message);
+ res.status(200).json({message: 'OTP sent successfully', otpCode: otp});
+ } catch (error) {
+ res.status(404).json({message: error});
+ }
+};
+
+export default {sendOTP};