Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web App not working properly on my local system. #2

Open
Andre-Shubham opened this issue Dec 11, 2024 · 4 comments
Open

Web App not working properly on my local system. #2

Andre-Shubham opened this issue Dec 11, 2024 · 4 comments

Comments

@Andre-Shubham
Copy link

Andre-Shubham commented Dec 11, 2024

I think jwtToken is responsible for the following undefined behaviour (sorry if I'm wrong 😅) :

  1. While new user Registration, "User registered successfully, login to proceed" alert is not showing (Register.jsx line 50).

  2. Account page is not showing any detail for student but working fine if a warden is logged in. Also, I'm not able to submit any complain as at the time of Registration, user data is not being input in student or warden tables. (userController.js from line 35).

Your project is Awesome, can you please help me resolve these issues ?

@Chinmay-Ankolekar
Copy link
Owner

Before adding complaints and student registration , add block details in block table then add other tables

@Andre-Shubham
Copy link
Author

I am trying to add " await db.pool.query("INSERT INTO block (block_name) VALUES ($1)", [block_id]); " in userController.js near line 30 (in the first try block).

I have also included " const { full_name, email, phone, password, type, block_id } = req.body; " block_id here before inserting it into db but it's still not working.

Is this repository missing some codes ?

@Chinmay-Ankolekar
Copy link
Owner

Add Block name and id, check db, if the block id is added or not, then register a new student or warden. Check all tables are created correctly.

@Andre-Shubham
Copy link
Author

block table and users table are being input properly and all tables and columns names are same as this repo, only the below code is not working I guess (also thank you so much for helping me 😅) :

const jwtToken = jwtGenerator(
newUser.rows[0].user_id,
newUser.rows[0].type
);

  if (type === "student") {
    const { block_id, usn, room } = req.body;
    console.log(newUser.rows);
    await db.pool.query(
      "INSERT INTO student (student_id, block_id, usn, room) VALUES ($1, $2, $3, $4)",
      [newUser.rows[0].user_id, block_id, usn, room]
    );
  } else if (type === "warden") {
    const { block_id } = req.body;
    await db.pool.query(
      "INSERT INTO warden (warden_id,block_id) VALUES ($1, $2)",
      [newUser.rows[0].user_id, block_id]
    );
  }
  console.log(jwtDecoder(jwtToken));
  return res.json({ jwtToken });
} catch (err) {
  console.error(err.message);
  res.status(500).send("Server error");
}

};

It is not giving error but it is also not inserting values in the desired tables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants