@@ -22,8 +22,6 @@ const sendOTP = async (req, res) => {
2222 const { email, walletAddress } = req . body ;
2323 const newOTP = generateOTP ( ) ;
2424
25- sendMailToSingerUser ( newOTP , email ) ;
26-
2725 const userDetails = {
2826 email,
2927 walletAddress,
@@ -41,6 +39,7 @@ const sendOTP = async (req, res) => {
4139 if ( userCheck . isMinted ) {
4240 return res . status ( 400 ) . json ( { error : "NFT is already minted for this user" } ) ;
4341 }
42+ sendMailToSingerUser ( newOTP , email ) ;
4443 newUser = await EthUser . findByIdAndUpdate (
4544 userCheck . _id ,
4645 userDetails ,
@@ -70,7 +69,8 @@ const verifyOTP = async (req, res) => {
7069 } )
7170 . lean ( ) ;
7271 if ( userCheck && userCheck . emailVerificationOTP == otp ) {
73- await EthUser . findByIdAndUpdate ( userCheck . _id , { isMinted : true , emailVerificationOTP : "" } ) ;
72+ // await EthUser.findByIdAndUpdate(userCheck._id, {isMinted: true, emailVerificationOTP: ""});
73+ await EthUser . findByIdAndUpdate ( userCheck . _id , { emailVerificationOTP : "" } ) ;
7474 return res . status ( 200 ) . json ( { message : "OTP Correct" , email : email } ) ;
7575 }
7676 return res . status ( 400 ) . json ( { error : "OTP not valid" } ) ;
@@ -79,7 +79,27 @@ const verifyOTP = async (req, res) => {
7979 }
8080} ;
8181
82+ const setMinted = async ( req , res ) => {
83+ try {
84+ const { email, walletAddress } = req . body ;
85+
86+ const userCheck = await EthUser . findOne ( {
87+ email : email ,
88+ } )
89+ . lean ( ) ;
90+ if ( userCheck ) {
91+ await EthUser . findByIdAndUpdate ( userCheck . _id , { isMinted : true , emailVerificationOTP : "" } ) ;
92+ return res . status ( 200 ) . json ( { message : "User set as minted" , email : email } ) ;
93+ }
94+ return res . status ( 400 ) . json ( { error : "Email not found" } ) ;
95+ } catch ( error ) {
96+ return res . status ( 400 ) . json ( { error : error . message } ) ;
97+ }
98+ } ;
99+
100+
82101module . exports = {
83102 sendOTP,
84- verifyOTP
103+ verifyOTP,
104+ setMinted
85105}
0 commit comments