From ea823049083d26609dfde61156d996a7fb53a9ff Mon Sep 17 00:00:00 2001
From: Suhani Singh Paliwal <161575955+suhanipaliwal@users.noreply.github.com>
Date: Wed, 15 May 2024 01:23:52 +0530
Subject: [PATCH 1/7] Create CONTRIBUTING.md
---
CONTRIBUTING.md | 47 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
create mode 100644 CONTRIBUTING.md
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..cee5c73
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,47 @@
+# **Contributing Guidelines** π
+
+This documentation contains a set of guidelines to help you during the contribution process.
+We are happy to welcome all the contributions from anyone willing to improve/add new scripts to this project.
+Thank you for helping out and remember, **no contribution is too small.**
+
+Please note we have a [code of conduct](CODE_OF_CONDUCT.md) please follow it in all your interactions with the project.
+
+
+
+
+
+## **Need some help regarding the basics?π€**
+
+
+You can refer to the following articles on basics of Git and Github and also contact the Project Mentors,
+in case you are stuck:
+
+- [Forking a Repo](https://help.github.com/en/github/getting-started-with-github/fork-a-repo)
+- [Cloning a Repo](https://help.github.com/en/desktop/contributing-to-projects/creating-an-issue-or-pull-request)
+- [How to create a Pull Request](https://opensource.com/article/19/7/create-pull-request-github)
+- [Getting started with Git and GitHub](https://towardsdatascience.com/getting-started-with-git-and-github-6fcd0f2d4ac6)
+- [Learn GitHub from Scratch](https://docs.github.com/en/get-started/start-your-journey/git-and-github-learning-resources)
+
+
+
+## **Issue Report Process π**
+
+1. Go to the project's issues.
+2. Give proper description for the issues.
+3. Don't spam to get the assignment of the issue π.
+4. Wait for till someone is looking into it !.
+5. Start working on issue only after you got assigned that issue π.
+
+
+
+## **Pull Request Process π**
+
+1. Ensure that you have self reviewed your code π
+2. Make sure you have added the proper description for the functionality of the code
+3. I have commented my code, particularly in hard-to-understand areas.
+4. Add screenshot it help in review.
+5. Submit your PR by giving the necesarry information in PR template and hang tight we will review it really soon π
+
+
+
+# **Thank you for contributingπ**
From 40ab028e529525e2d5622329b8797e38fac55816 Mon Sep 17 00:00:00 2001
From: Akshat Jain <129594034+its-AkshatJain@users.noreply.github.com>
Date: Wed, 15 May 2024 02:11:24 +0530
Subject: [PATCH 2/7] Hashed password NgoRoutes.js
I have improved the error handling of NGO-login.
I have added hashing to the NGO registration password.
---
routers/NgoRoutes.js | 190 ++++++++++++++-----------------------------
1 file changed, 59 insertions(+), 131 deletions(-)
diff --git a/routers/NgoRoutes.js b/routers/NgoRoutes.js
index 0053d28..dd3c397 100644
--- a/routers/NgoRoutes.js
+++ b/routers/NgoRoutes.js
@@ -11,154 +11,82 @@ const NGO=require("../model/ngo")
const Query = require("../model/query"); // Adjust the path based on your project structure
-router.post("/NGO-login",async(req,res)=>{
+router.post("/NGO-login", async (req, res) => {
const username = req.body.username;
const password = req.body.password;
- const ngo = await NGO.findOne({ username: username, password: password });
try {
+ const ngo = await NGO.findOne({ username: username, password: password });
+ if (!ngo) {
+ return res.status(400).json({ error: 'NGO not found' });
+ }
+ const isPasswordValid = await bcrypt.compare(password, ngo.password);
+ if (!isPasswordValid) {
+ return res.status(400).json({ error: 'Invalid credentials' });
+ }
const dooner = await User.find(); // Assuming User is your Mongoose model for users
-
-
-
res.render("NGO-Dashboard", {
fullName: ngo.NGOName,
email: ngo.username,
- id: ngo.NGOID,
- phoneNo:ngo.Mobile,
- address :ngo.NGOLocation,
- Donation : dooner,
- Pickup : dooner,
+ id: ngo.NgoID,
+ phoneNo: ngo.Mobile,
+ address: ngo.NgoLocation,
+ Donation: dooner,
+ Pickup: dooner,
complain: ""
});
} catch (err) {
console.error(err);
res.status(500).send("An internal server error occurred.");
}
- })
-
- router.post("/NGO-Registarion", async (req, res) => {
- // Check if the NGO already exists
- const existingNGO = await NGO.findOne({ username: req.body.username });
- if (existingNGO) {
- return res.status(400).json({ error: 'NGO already exists' });
- }
-
- // Create a new NGO registration
- const newNGO = new NGO({
- username: req.body.username,
- password: req.body.password,
- NGOName: req.body.NGOName,
- Mobile: req.body.Mobile,
- NGOID: req.body.NGOID,
- NGOLocation: req.body.NGOLocation,
- approved: false
- });
-
- // Save the new NGO to the database
+});
+router.post("/NGO-Registration", async (req, res) => {
try {
- // Save the new NGO to the database
- await newNGO.save();
-
- // Send an email to the admin for approval
- let mailOptions = {
- to:newNGO.username, // Admin's email address
- subject: 'New NGO Registration',
- text: 'A new NGO registration is pending approval. Login to the admin panel to review and approve.',
- // Include any necessary information in the email body
- };
- transporter.sendMail(mailOptions, function (error, info) {
- if (error) {
- console.log(error);
- } else {
- console.log('Email sent: ' + info.response);
- }
- });
-
- console.log('NGO registration request sent for approval');
- res.status(200).json({ message: 'NGO registration request sent for approval' });
- } catch (err) {
- console.error('Error creating NGO:', err);
- res.status(500).json({ error: 'Internal server error' });
- }
- // try {
- // await newNGO.save();
-
- // let mailOptions = {
- // to: newNGO.username,
- // subject: 'Welcome To Petari',
- // template: 'Email.template',
- // context: {
- // ngo: {
- // ngoName: newNGO.name,
- // _id: newNGO._id,
- // username: newNGO.password,
- // },
- // year: new Date().getFullYear()
- // },
- // attachments: [{
- // filename: 'logo.png',
- // path: path.join(__dirname, 'public', 'img', 'logo.png'),
- // cid: 'logo'
- // }]
- // };
-
- // transporter.sendMail(mailOptions, function(error, info){
- // if (error) {
- // console.log(error);
- // } else {
- // console.log('Email sent: ' + info.response);
- // }
- // });
-
- // console.log('NGO registered successfully');
- // res.status(200).json({ message: 'NGO registration received. It will be reviewed by the admin.' });
- // } catch (err) {
- // console.error('Error creating NGO:', err);
- // res.status(500).json({ error: 'Internal server error' });
- // }
- // newNGO.save()
- // .then((ngo) => {
- // let mailOptions = {
- // to: ngo.username,
- // subject: 'Welcome To Petari',
- // template: 'Email.template',
- // context: {
- // ngo: {
- // ngoName: ngo.name,
- // _id: ngo._id,
- // username: ngo.password,
-
- // },
-
- // year: new Date().getFullYear()
- // },
- // attachments: [{
- // filename: 'logo.png',
- // path: path.join(__dirname, 'public', 'img', 'logo.png'),
- // cid: 'logo'
- // }]
- // };
- // transporter.sendMail(mailOptions, function(error, info){
- // if (error) {
- // console.log(error);
- // } else {
- // console.log('Email sent: ' + info.response);
- // }
- // });
+ // Check if the NGO already exists
+ const existingNGO = await NGO.findOne({ username: req.body.username });
+ if (existingNGO) {
+ return res.status(400).json({ error: 'NGO already exists' });
+ }
+
+ // Hash the password for security
+ const hashedPassword = await bcrypt.hash(req.body.password, saltRounds);
+
+ // Create a new NGO registration
+ const newNGO = new NGO({
+ username: req.body.username,
+ password: hashedPassword, // Save the hashed password
+ NGOName: req.body.NGOName,
+ Mobile: req.body.Mobile,
+ NgoID: req.body.NgoID,
+ NgoLocation: req.body.NgoLocation,
+ approved: false
+ });
- // console.log('NGO registered successfully');
- // res.status(200).json({ message: 'NGO registered successfully' });
+ // Save the new NGO to the database
+ await newNGO.save();
+
+ // Send an email to the admin for approval
+ let mailOptions = {
+ to:newNGO.username, // Admin's email address
+ subject: 'New NGO Registration',
+ text: 'A new NGO registration is pending approval. Login to the admin panel to review and approve.',
+ // Include any necessary information in the email body
+ };
+ transporter.sendMail(mailOptions, function (error, info) {
+ if (error) {
+ console.log(error);
+ } else {
+ console.log('Email sent: ' + info.response);
+ }
+ });
- // })
- // .catch((err) => {
- // console.error('Error creating NGO:', err);
- // res.status(500).json({ error: 'Internal server error' });
- // });
+ console.log('NGO registration request sent for approval');
+ res.status(200).json({ message: 'NGO registration request sent for approval' });
+ } catch (err) {
+ console.error('Error creating NGO:', err);
+ res.status(500).json({ error: 'Internal server error' });
+ }
});
+module.exports = router;
-
-
-
-module.exports = router
\ No newline at end of file
From 967bfb93c0d6fccd209b5555def8a20aace0c0c0 Mon Sep 17 00:00:00 2001
From: Akshat Jain <129594034+its-AkshatJain@users.noreply.github.com>
Date: Wed, 15 May 2024 02:14:13 +0530
Subject: [PATCH 3/7] Corrected path of form in NGO-Registration.ejs
In form action the path is incorrect.
---
views/NGO-Registration.ejs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/views/NGO-Registration.ejs b/views/NGO-Registration.ejs
index e4e1a3c..a11e14a 100644
--- a/views/NGO-Registration.ejs
+++ b/views/NGO-Registration.ejs
@@ -93,7 +93,7 @@