diff --git a/server/src/app.js b/server/src/app.js index 8065b59..5b98050 100644 --- a/server/src/app.js +++ b/server/src/app.js @@ -19,7 +19,8 @@ var corsOptions = { }; if (process.env.NODE_ENV === "production") { - corsOptions.origin = "https://communityofcoders.in"; + // corsOptions.origin = "https://communityofcoders.in"; + corsOptions.origin = "*"; } app.use(cors(corsOptions)); @@ -34,8 +35,11 @@ routes(app); dbconnect(rescheduler.reschedule); -app.use(compression()); -app.use(express.static(path.join(__dirname, "../../new_client/build"))); +app.get("/ethvjti", (req, res) => { + res.send({"ok": "ok"}); +}); + +app.use(express.static(path.resolve(__dirname, "../../new_client/build"))); app.get("/*", (req, res) => { res.sendFile(path.join(__dirname, "../../new_client/build/index.html")); diff --git a/server/src/controllers/EthVJTIController.js b/server/src/controllers/EthVJTIController.js index caee340..3379aa3 100644 --- a/server/src/controllers/EthVJTIController.js +++ b/server/src/controllers/EthVJTIController.js @@ -22,8 +22,6 @@ const sendOTP = async (req, res) => { const { email, walletAddress } = req.body; const newOTP = generateOTP(); - sendMailToSingerUser(newOTP, email); - const userDetails = { email, walletAddress, @@ -41,6 +39,7 @@ const sendOTP = async (req, res) => { if(userCheck.isMinted){ return res.status(400).json({ error: "NFT is already minted for this user" }); } + sendMailToSingerUser(newOTP, email); newUser = await EthUser.findByIdAndUpdate( userCheck._id, userDetails, @@ -70,7 +69,8 @@ const verifyOTP = async (req, res) => { }) .lean(); if(userCheck && userCheck.emailVerificationOTP == otp){ - await EthUser.findByIdAndUpdate(userCheck._id, {isMinted: true, emailVerificationOTP: ""}); + // await EthUser.findByIdAndUpdate(userCheck._id, {isMinted: true, emailVerificationOTP: ""}); + await EthUser.findByIdAndUpdate(userCheck._id, {emailVerificationOTP: ""}); return res.status(200).json({ message: "OTP Correct", email: email }); } return res.status(400).json({ error: "OTP not valid" }); @@ -79,7 +79,27 @@ const verifyOTP = async (req, res) => { } }; +const setMinted = async (req, res) => { + try { + const { email, walletAddress } = req.body; + + const userCheck = await EthUser.findOne({ + email: email, + }) + .lean(); + if(userCheck){ + await EthUser.findByIdAndUpdate(userCheck._id, {isMinted: true, emailVerificationOTP: ""}); + return res.status(200).json({ message: "User set as minted", email: email }); + } + return res.status(400).json({ error: "Email not found" }); + } catch (error) { + return res.status(400).json({ error: error.message }); + } +}; + + module.exports = { sendOTP, - verifyOTP + verifyOTP, + setMinted } \ No newline at end of file diff --git a/server/src/routes.js b/server/src/routes.js index cec1738..0d2c3a9 100644 --- a/server/src/routes.js +++ b/server/src/routes.js @@ -324,6 +324,7 @@ module.exports = (app) => { // EthVJTI app.post('/api/ethvjti/sendotp', EthVJTIController.sendOTP); app.get('/api/ethvjti/verifyotp', EthVJTIController.verifyOTP); + app.get('/api/ethvjti/setminted', EthVJTIController.setMinted); }