const express = require("express");
const router = express.Router();
const User = require("../models/User");
const { sendVerificationCode, validateVerificationCode } = require("../utils/sms");
router.post("/register", async (req, res) => {
const { phoneNumber, verificationCode } = req.body;
// Send a verification code to the user's phone number
const code = await sendVerificationCode(phoneNumber);
// Validate the verification code
const isValid = await validateVerificationCode(phoneNumber, verificationCode);
if (!isValid) {
return res.status(400).json({ error: "Invalid verification code" });
}
// Create a new user account
const user = new User({ phoneNumber });
await user.save();
res.json({ message: "User registered successfully" });
});
module.exports = router;
const express = require("express");
const router = express.Router();
const User = require("../models/User");
const { sendVerificationCode, validateVerificationCode } = require("../utils/sms");
router.post("/register", async (req, res) => {
const { phoneNumber, verificationCode } = req.body;
// Send a verification code to the user's phone number
const code = await sendVerificationCode(phoneNumber);
// Validate the verification code
const isValid = await validateVerificationCode(phoneNumber, verificationCode);
if (!isValid) {
return res.status(400).json({ error: "Invalid verification code" });
}
// Create a new user account
const user = new User({ phoneNumber });
await user.save();
res.json({ message: "User registered successfully" });
});
module.exports = router;
const express = require("express");
const router = express.Router();
const User = require("../models/User");
const { sendVerificationCode, validateVerificationCode } = require("../utils/sms");
router.post("/register", async (req, res) => {
const { phoneNumber, verificationCode } = req.body;
// Send a verification code to the user's phone number
const code = await sendVerificationCode(phoneNumber);
// Validate the verification code
const isValid = await validateVerificationCode(phoneNumber, verificationCode);
if (!isValid) {
return res.status(400).json({ error: "Invalid verification code" });
}
// Create a new user account
const user = new User({ phoneNumber });
await user.save();
res.json({ message: "User registered successfully" });
});
module.exports = router;
const express = require("express");
const router = express.Router();
const User = require("../models/User");
const { sendVerificationCode, validateVerificationCode } = require("../utils/sms");
router.post("/register", async (req, res) => {
const { phoneNumber, verificationCode } = req.body;
// Send a verification code to the user's phone number
const code = await sendVerificationCode(phoneNumber);
// Validate the verification code
const isValid = await validateVerificationCode(phoneNumber, verificationCode);
if (!isValid) {
return res.status(400).json({ error: "Invalid verification code" });
}
// Create a new user account
const user = new User({ phoneNumber });
await user.save();
res.json({ message: "User registered successfully" });
});
module.exports = router;
const express = require("express");
const router = express.Router();
const User = require("../models/User");
const { sendVerificationCode, validateVerificationCode } = require("../utils/sms");
router.post("/register", async (req, res) => {
const { phoneNumber, verificationCode } = req.body;
// Send a verification code to the user's phone number
const code = await sendVerificationCode(phoneNumber);
// Validate the verification code
const isValid = await validateVerificationCode(phoneNumber, verificationCode);
if (!isValid) {
return res.status(400).json({ error: "Invalid verification code" });
}
// Create a new user account
const user = new User({ phoneNumber });
await user.save();
res.json({ message: "User registered successfully" });
});
module.exports = router;
const express = require("express");
const router = express.Router();
const User = require("../models/User");
const { sendVerificationCode, validateVerificationCode } = require("../utils/sms");
router.post("/register", async (req, res) => {
const { phoneNumber, verificationCode } = req.body;
// Send a verification code to the user's phone number
const code = await sendVerificationCode(phoneNumber);
// Validate the verification code
const isValid = await validateVerificationCode(phoneNumber, verificationCode);
if (!isValid) {
return res.status(400).json({ error: "Invalid verification code" });
}
// Create a new user account
const user = new User({ phoneNumber });
await user.save();
res.json({ message: "User registered successfully" });
});
module.exports = router;
const express = require("express");
const router = express.Router();
const User = require("../models/User");
const { sendVerificationCode, validateVerificationCode } = require("../utils/sms");
router.post("/register", async (req, res) => {
const { phoneNumber, verificationCode } = req.body;
// Send a verification code to the user's phone number
const code = await sendVerificationCode(phoneNumber);
// Validate the verification code
const isValid = await validateVerificationCode(phoneNumber, verificationCode);
if (!isValid) {
return res.status(400).json({ error: "Invalid verification code" });
}
// Create a new user account
const user = new User({ phoneNumber });
await user.save();
res.json({ message: "User registered successfully" });
});
module.exports = router;
const express = require("express");
const router = express.Router();
const User = require("../models/User");
const { sendVerificationCode, validateVerificationCode } = require("../utils/sms");
router.post("/register", async (req, res) => {
const { phoneNumber, verificationCode } = req.body;
// Send a verification code to the user's phone number
const code = await sendVerificationCode(phoneNumber);
// Validate the verification code
const isValid = await validateVerificationCode(phoneNumber, verificationCode);
if (!isValid) {
return res.status(400).json({ error: "Invalid verification code" });
}
// Create a new user account
const user = new User({ phoneNumber });
await user.save();
res.json({ message: "User registered successfully" });
});
module.exports = router;
const express = require("express");
const router = express.Router();
const User = require("../models/User");
const { sendVerificationCode, validateVerificationCode } = require("../utils/sms");
router.post("/register", async (req, res) => {
const { phoneNumber, verificationCode } = req.body;
// Send a verification code to the user's phone number
const code = await sendVerificationCode(phoneNumber);
// Validate the verification code
const isValid = await validateVerificationCode(phoneNumber, verificationCode);
if (!isValid) {
return res.status(400).json({ error: "Invalid verification code" });
}
// Create a new user account
const user = new User({ phoneNumber });
await user.save();
res.json({ message: "User registered successfully" });
});
module.exports = router;
const express = require("express");
const router = express.Router();
const User = require("../models/User");
const { sendVerificationCode, validateVerificationCode } = require("../utils/sms");
router.post("/register", async (req, res) => {
const { phoneNumber, verificationCode } = req.body;
// Send a verification code to the user's phone number
const code = await sendVerificationCode(phoneNumber);
// Validate the verification code
const isValid = await validateVerificationCode(phoneNumber, verificationCode);
if (!isValid) {
return res.status(400).json({ error: "Invalid verification code" });
}
// Create a new user account
const user = new User({ phoneNumber });
await user.save();
res.json({ message: "User registered successfully" });
});
module.exports = router;
const express = require("express");
const router = express.Router();
const User = require("../models/User");
const { sendVerificationCode, validateVerificationCode } = require("../utils/sms");
router.post("/register", async (req, res) => {
const { phoneNumber, verificationCode } = req.body;
// Send a verification code to the user's phone number
const code = await sendVerificationCode(phoneNumber);
// Validate the verification code
const isValid = await validateVerificationCode(phoneNumber, verificationCode);
if (!isValid) {
return res.status(400).json({ error: "Invalid verification code" });
}
// Create a new user account
const user = new User({ phoneNumber });
await user.save();
res.json({ message: "User registered successfully" });
});
module.exports = router;
const express = require("express");
const router = express.Router();
const User = require("../models/User");
const { sendVerificationCode, validateVerificationCode } = require("../utils/sms");
router.post("/register", async (req, res) => {
const { phoneNumber, verificationCode } = req.body;
// Send a verification code to the user's phone number
const code = await sendVerificationCode(phoneNumber);
// Validate the verification code
const isValid = await validateVerificationCode(phoneNumber, verificationCode);
if (!isValid) {
return res.status(400).json({ error: "Invalid verification code" });
}
// Create a new user account
const user = new User({ phoneNumber });
await user.save();
res.json({ message: "User registered successfully" });
});
module.exports = router;
const express = require("express");
const router = express.Router();
const User = require("../models/User");
const { sendVerificationCode, validateVerificationCode } = require("../utils/sms");
router.post("/register", async (req, res) => {
const { phoneNumber, verificationCode } = req.body;
// Send a verification code to the user's phone number
const code = await sendVerificationCode(phoneNumber);
// Validate the verification code
const isValid = await validateVerificationCode(phoneNumber, verificationCode);
if (!isValid) {
return res.status(400).json({ error: "Invalid verification code" });
}
// Create a new user account
const user = new User({ phoneNumber });
await user.save();
res.json({ message: "User registered successfully" });
});
module.exports = router;
const express = require("express");
const router = express.Router();
const User = require("../models/User");
const { sendVerificationCode, validateVerificationCode } = require("../utils/sms");
router.post("/register", async (req, res) => {
const { phoneNumber, verificationCode } = req.body;
// Send a verification code to the user's phone number
const code = await sendVerificationCode(phoneNumber);
// Validate the verification code
const isValid = await validateVerificationCode(phoneNumber, verificationCode);
if (!isValid) {
return res.status(400).json({ error: "Invalid verification code" });
}
// Create a new user account
const user = new User({ phoneNumber });
await user.save();
res.json({ message: "User registered successfully" });
});
module.exports = router;
const express = require("express");
const router = express.Router();
const User = require("../models/User");
const { sendVerificationCode, validateVerificationCode } = require("../utils/sms");
router.post("/register", async (req, res) => {
const { phoneNumber, verificationCode } = req.body;
// Send a verification code to the user's phone number
const code = await sendVerificationCode(phoneNumber);
// Validate the verification code
const isValid = await validateVerificationCode(phoneNumber, verificationCode);
if (!isValid) {
return res.status(400).json({ error: "Invalid verification code" });
}
// Create a new user account
const user = new User({ phoneNumber });
await user.save();
res.json({ message: "User registered successfully" });
});
module.exports = router;
const express = require("express");
const router = express.Router();
const User = require("../models/User");
const { sendVerificationCode, validateVerificationCode } = require("../utils/sms");
router.post("/register", async (req, res) => {
const { phoneNumber, verificationCode } = req.body;
// Send a verification code to the user's phone number
const code = await sendVerificationCode(phoneNumber);
// Validate the verification code
const isValid = await validateVerificationCode(phoneNumber, verificationCode);
if (!isValid) {
return res.status(400).json({ error: "Invalid verification code" });
}
// Create a new user account
const user = new User({ phoneNumber });
await user.save();
res.json({ message: "User registered successfully" });
});
module.exports = router;
const express = require("express");
const router = express.Router();
const User = require("../models/User");
const { sendVerificationCode, validateVerificationCode } = require("../utils/sms");
router.post("/register", async (req, res) => {
const { phoneNumber, verificationCode } = req.body;
// Send a verification code to the user's phone number
const code = await sendVerificationCode(phoneNumber);
// Validate the verification code
const isValid = await validateVerificationCode(phoneNumber, verificationCode);
if (!isValid) {
return res.status(400).json({ error: "Invalid verification code" });
}
// Create a new user account
const user = new User({ phoneNumber });
await user.save();
res.json({ message: "User registered successfully" });
});
module.exports = router;