Skip to content

Commit

Permalink
fix sign up issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mohdzain98 committed Jun 29, 2024
1 parent 4479399 commit 8d1e4d4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Microservices/User_auth/routes/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 6 additions & 8 deletions src/Components/Signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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')
Expand All @@ -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`, {
Expand All @@ -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){
Expand Down

0 comments on commit 8d1e4d4

Please sign in to comment.