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

merge features branch to prafful branch #22

Merged
merged 20 commits into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
722f603
Merge pull request #6 from kushwahramkumar2003/prafful
kushwahramkumar2003 Nov 19, 2023
16747d6
Fix variable name in quiz.controllers.js
Nov 19, 2023
9eb3b20
Merge pull request #7 from kushwahramkumar2003/pankaj
kushwahramkumar2003 Nov 27, 2023
ed7cd79
Merge pull request #8 from kushwahramkumar2003/main
kushwahramkumar2003 Nov 27, 2023
da3ef59
Merge pull request #9 from kushwahramkumar2003/Prafful
kushwahramkumar2003 Nov 28, 2023
08f3d86
Merge pull request #12 from kushwahramkumar2003/Prafful
kushwahramkumar2003 Nov 28, 2023
8bee81c
Merge pull request #13 from kushwahramkumar2003/main
kushwahramkumar2003 Nov 28, 2023
d1685bf
Merge pull request #14 from kushwahramkumar2003/features
kushwahramkumar2003 Nov 28, 2023
771af2d
Merge pull request #15 from kushwahramkumar2003/ram
kushwahramkumar2003 Nov 28, 2023
b8d347f
Merge pull request #18 from kushwahramkumar2003/Prafful
kushwahramkumar2003 Dec 1, 2023
73c3cdd
Delete unnecessary files and update JWT_SECRET in
Dec 8, 2023
d4f20f2
Fix menu links and add alt attribute to logo image and also refector …
Dec 8, 2023
0cccb51
Refactor quiz controllers and add EditQuiz page
Dec 8, 2023
695bc29
Update dependencies and delete unused files also add func. to add new…
Dec 8, 2023
3a4839d
Add new question feature to EditQuiz component
Dec 8, 2023
4d56024
Fix delete functionality in quiz.controllers.js
Dec 8, 2023
ea7f6f6
Fix role check and add console logs
Dec 9, 2023
1161860
Merge pull request #19 from kushwahramkumar2003/ram
kushwahramkumar2003 Dec 9, 2023
795381f
Merge pull request #20 from kushwahramkumar2003/features
kushwahramkumar2003 Dec 9, 2023
ba13a38
Merge pull request #21 from kushwahramkumar2003/main
kushwahramkumar2003 Dec 9, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Server/src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
MONGODB_URL: process.env.MONGODB_URL || "mongodb://localhost:27017/quiz-app",
PORT: process.env.PORT || 3001,

JWT_SECRET: process.env.JWT_SECRET,
JWT_SECRET: process.env.JWT_SECRET || "thisisasecret",

Check failure

Code scanning / CodeQL

Hard-coded credentials Critical

The hard-coded value "thisisasecret" is used as
key
.
The hard-coded value "thisisasecret" is used as
key
.
JWT_EXPIRE: process.env.JWT_EXPIRE || "1d",

SMTP_HOST: process.env.SMTP_HOST,
Expand Down
6 changes: 4 additions & 2 deletions Server/src/controllers/auth.controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@

const { email, password } = req.body;

let user = await User.findOne({ email }, { email: 1, password: 1, name: 1 });
let user = await User.findOne(
{ email },

Check failure

Code scanning / CodeQL

Database query built from user-controlled sources High

This query object depends on a
user-provided value
.
{ email: 1, password: 1, name: 1, role: 1 }
);
// console.log("user", user);
if (!user) {
return res.status(400).json({ msg: "Invalid Credentials" });
Expand All @@ -78,7 +81,6 @@
res.status(200).json({
success: true,
message: "User logged in successfully",
data: user,
user,
});
});
Expand Down
16 changes: 7 additions & 9 deletions Server/src/controllers/quiz.controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ exports.addQuestionToQuiz = asyncHandler(async (req, res) => {
* @kushwahramkumar2003
**************************************************************************/
exports.getAllQuizzes = asyncHandler(async (req, res) => {
const quizzes = await Quiz.find({}, { questions: 0 }).populate().exec();
const quizzes = await Quiz.find({}).populate().exec();
res.json(quizzes);
});

Expand All @@ -114,7 +114,7 @@ exports.getAllQuizzes = asyncHandler(async (req, res) => {
*************************************************************************/
exports.getQuizById = asyncHandler(async (req, res) => {
const quiz = await Quiz.findById(req.params.id)
.populate("questions", "text options")
.populate("questions", "text options answer")
.exec();
if (quiz) {
res.json(quiz);
Expand Down Expand Up @@ -214,7 +214,7 @@ exports.deleteQuizById = asyncHandler(async (req, res) => {
await Question.deleteMany({ quiz: quizId });

// Delete all results corresponding to the quiz
await Result.deleteMany({ quiz: quizId });
await QuizResult.deleteMany({ quiz: quizId });

// Delete the quiz itself
// await Quiz.findByIdAndDelete(quizId);
Expand All @@ -238,16 +238,14 @@ exports.deleteQuestionById = asyncHandler(async (req, res) => {
return res.status(404).json({ success: false, message: "Quiz not found" });
}

const question = await Question.findById(questionId);
const question = await Question.findOneAndDelete(questionId);

if (!question) {
return res
.status(404)
.json({ success: false, message: "Question not found" });
}

await question.remove();

res
.status(200)
.json({ success: true, message: "Question deleted successfully" });
Expand Down Expand Up @@ -347,7 +345,7 @@ exports.getQuizResults = asyncHandler(async (req, res) => {
return res.status(404).json({ message: "Quiz not found" });
}

const results = await Result.find({ quiz: quiz._id }).populate(
const results = await QuizResult.find({ quiz: quiz._id }).populate(
"user",
"name email"
);
Expand Down Expand Up @@ -452,7 +450,7 @@ exports.submitQuizOnTimeUp = asyncHandler(async (req, res) => {
exports.getQuizResultsForUser = asyncHandler(async (req, res) => {
try {
const { id, userId } = req.params;
const quizResults = await QuizResults.findOne({
const quizResults = await QuizResult.findOne({
quiz: id,
user: userId,
}).populate("quiz", "title");
Expand All @@ -474,7 +472,7 @@ exports.getQuizResultsForUser = asyncHandler(async (req, res) => {
exports.getAllResultsForQuiz = asyncHandler(async (req, res) => {
try {
const { id } = req.params;
const quizResults = await QuizResults.find({ quiz: id }).populate(
const quizResults = await QuizResult.find({ quiz: id }).populate(
"user",
"name email"
);
Expand Down
Loading
Loading