From 8d1e4d4eaad5ba42bb6123ba10ae40a831a733ac Mon Sep 17 00:00:00 2001 From: Mohd Zain Date: Sun, 30 Jun 2024 00:40:51 +0530 Subject: [PATCH] fix sign up issue --- Microservices/User_auth/routes/auth.js | 2 +- src/Components/Signup.js | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Microservices/User_auth/routes/auth.js b/Microservices/User_auth/routes/auth.js index 45f079d..3338a60 100755 --- a/Microservices/User_auth/routes/auth.js +++ b/Microservices/User_auth/routes/auth.js @@ -35,7 +35,7 @@ router.post('/createuser',[ //if there are error return bad request const errors = validationResult(req); if(!errors.isEmpty()){ - return res.status(400).json({errors:errors.array()}) + return res.status(500).json({msg:'error occurred',errors:errors.array()}) } // check email already exist diff --git a/src/Components/Signup.js b/src/Components/Signup.js index 6ef1617..61eb2ea 100755 --- a/src/Components/Signup.js +++ b/src/Components/Signup.js @@ -42,12 +42,9 @@ const Signup = (props) => { } ) const data = await response.json() - const email = await data.email - const name = await data.name - const id = await data.id - setCred({name:name,email:email,password:id,cpassword:id}) - handleSubmit() + handleSubmit(data.name, data.email, data.id, data.id) } + const onChangeModal = (e)=>{ setOtp(e.target.value) } @@ -127,7 +124,7 @@ const Signup = (props) => { if(resp.success){ modalClose.current.click() showAlert('OTP verified Successully','primary') - handleSubmit() + handleSubmit(cred.name, cred.email, cred.password, cred.cpassword) setMloader("") }else{ setValid('visible') @@ -145,8 +142,8 @@ const Signup = (props) => { onError: (error) => showAlert(`${error} - Kindly Signup Manually`,'danger') }); - const handleSubmit = async (e)=>{ - const {name, email,password, cpassword} = cred + const handleSubmit = async (name,email,password,cpassword)=>{ + // const {name, email,password, cpassword} = cred if(password === cpassword){ setLoader("spinner-border m-2") const response = await fetch(`${host}/api/auth/createuser`, { @@ -159,6 +156,7 @@ const Signup = (props) => { if(response.status === 500){ showAlert("Internal Server Error Occurred","danger") setLoader("") + setCred({name:"", email:"", password:"", cpassword:""}) }else{ const json = await response.json() if(json.success){