-
Notifications
You must be signed in to change notification settings - Fork 318
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
Bug: Reset password fixed #1083
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,43 @@ | ||
const to = require("await-to-js").default; | ||
const to = require('await-to-js').default; | ||
|
||
const constants = require("../../../../constants"); | ||
const { ErrorHandler } = require("../../../../helpers/error"); | ||
const constants = require('../../../../constants'); | ||
const { ErrorHandler } = require('../../../../helpers/error'); | ||
|
||
const answers = require("../../../models/answers"); | ||
const answers = require('../../../models/answers'); | ||
|
||
module.exports = async (req, res, next) => { | ||
// getting id and status from body | ||
const id = req.body.id; | ||
const status = req.body.status | ||
|
||
// query fro updating | ||
const [ err, result ] = await to(answers.findOneAndUpdate({ _id : id }, { $set : { isApproved : status } })); | ||
|
||
// error occured due to the some problem | ||
if(err) { | ||
const error = new ErrorHandler(constants.ERRORS.DATABASE, { | ||
statusCode: 500, | ||
message: 'Database Error', | ||
errStack: err, | ||
}); | ||
|
||
return next(error); | ||
} | ||
|
||
// if result is null that means answer with given id is not exist in collection | ||
if(result === null) { | ||
const answerNotExistError = new ErrorHandler(constants.ERRORS.INPUT, { | ||
statusCode: 400, | ||
message: 'Answer Not Exist...', | ||
}); | ||
|
||
return next(answerNotExistError); | ||
} | ||
|
||
// success response | ||
res.status(200).send({ | ||
message : "Status Updated..." | ||
// getting id and status from body | ||
const { id } = req.body; | ||
const { status } = req.body; | ||
|
||
// query fro updating | ||
const [err, result] = await to(answers.findOneAndUpdate({ _id: id }, { $set: { isApproved: status } })); | ||
|
||
// error occured due to the some problem | ||
if (err) { | ||
const error = new ErrorHandler(constants.ERRORS.DATABASE, { | ||
statusCode: 500, | ||
message: 'Database Error', | ||
errStack: err, | ||
}); | ||
|
||
return next(); | ||
} | ||
return next(error); | ||
} | ||
|
||
// if result is null that means answer with given id is not exist in collection | ||
if (result === null) { | ||
const answerNotExistError = new ErrorHandler(constants.ERRORS.INPUT, { | ||
statusCode: 400, | ||
message: 'Answer Not Exist...', | ||
}); | ||
|
||
return next(answerNotExistError); | ||
} | ||
|
||
// success response | ||
res.status(200).send({ | ||
message: 'Status Updated...', | ||
}); | ||
|
||
return next(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,43 @@ | ||
const to = require("await-to-js").default; | ||
const to = require('await-to-js').default; | ||
|
||
const constants = require("../../../../constants"); | ||
const { ErrorHandler } = require("../../../../helpers/error"); | ||
const constants = require('../../../../constants'); | ||
const { ErrorHandler } = require('../../../../helpers/error'); | ||
|
||
const question = require("../../../models/question"); | ||
const question = require('../../../models/question'); | ||
|
||
module.exports = async (req, res, next) => { | ||
// getting id and status from body | ||
const id = req.body.id; | ||
const status = req.body.status | ||
|
||
// query fro updating | ||
const [ err, result ] = await to(question.findOneAndUpdate({ _id : id }, { $set : { isApproved : status } })); | ||
|
||
// error occured due to the some problem | ||
if(err) { | ||
const error = new ErrorHandler(constants.ERRORS.DATABASE, { | ||
statusCode: 500, | ||
message: 'Database Error', | ||
errStack: err, | ||
}); | ||
|
||
return next(error); | ||
} | ||
|
||
// if result is null that means question with given id is not exist in collection | ||
if(result === null) { | ||
const questionNotExistsError = new ErrorHandler(constants.ERRORS.INPUT, { | ||
statusCode: 400, | ||
message: 'Question Not Exist...', | ||
}); | ||
|
||
return next(questionNotExistsError); | ||
} | ||
|
||
// success response | ||
res.status(200).send({ | ||
message : "Status Updated..." | ||
// getting id and status from body | ||
const { id } = req.body; | ||
const { status } = req.body; | ||
|
||
// query fro updating | ||
const [err, result] = await to(question.findOneAndUpdate({ _id: id }, { $set: { isApproved: status } })); | ||
Check failure Code scanning / CodeQL Database query built from user-controlled sources High
This query object depends on a
user-provided value Error loading related location Loading |
||
|
||
// error occured due to the some problem | ||
if (err) { | ||
const error = new ErrorHandler(constants.ERRORS.DATABASE, { | ||
statusCode: 500, | ||
message: 'Database Error', | ||
errStack: err, | ||
}); | ||
|
||
return next(); | ||
} | ||
return next(error); | ||
} | ||
|
||
// if result is null that means question with given id is not exist in collection | ||
if (result === null) { | ||
const questionNotExistsError = new ErrorHandler(constants.ERRORS.INPUT, { | ||
statusCode: 400, | ||
message: 'Question Not Exist...', | ||
}); | ||
|
||
return next(questionNotExistsError); | ||
} | ||
|
||
// success response | ||
res.status(200).send({ | ||
message: 'Status Updated...', | ||
}); | ||
|
||
return next(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,45 @@ | ||
const { default: to } = require("await-to-js"); | ||
const constants = require("../../../constants"); | ||
const { ErrorHandler } = require("../../../helpers/error"); | ||
const Admin = require("../../models/Admin"); | ||
const { default: to } = require('await-to-js'); | ||
const constants = require('../../../constants'); | ||
const { ErrorHandler } = require('../../../helpers/error'); | ||
const Admin = require('../../models/Admin'); | ||
|
||
module.exports = async (req, res, next) => { | ||
const { isSuperAdmin } = res.locals.decode; | ||
const { isSuperAdmin } = res.locals.decode; | ||
|
||
if(!isSuperAdmin) { | ||
const error = new ErrorHandler(constants.ERRORS.INPUT, { | ||
statusCode: 401, | ||
message: 'Unauthorized Request: Not a superAdmin', | ||
user: req.body.email, | ||
}); | ||
if (!isSuperAdmin) { | ||
const error = new ErrorHandler(constants.ERRORS.INPUT, { | ||
statusCode: 401, | ||
message: 'Unauthorized Request: Not a superAdmin', | ||
user: req.body.email, | ||
}); | ||
|
||
return next(error); | ||
} | ||
return next(error); | ||
} | ||
|
||
const id = req.body.id; | ||
const { id } = req.body; | ||
|
||
const [err, admin] = await to(Admin.findByIdAndDelete(id)); | ||
const [err, admin] = await to(Admin.findByIdAndDelete(id)); | ||
Check failure Code scanning / CodeQL Database query built from user-controlled sources High
This query object depends on a
user-provided value Error loading related location Loading |
||
|
||
if (!admin) { | ||
const error = new ErrorHandler(constants.ERRORS.INPUT, { | ||
statusCode: 400, | ||
message: "Admin doesn't exist", | ||
}); | ||
if (!admin) { | ||
const error = new ErrorHandler(constants.ERRORS.INPUT, { | ||
statusCode: 400, | ||
message: "Admin doesn't exist", | ||
}); | ||
|
||
return next(error); | ||
} | ||
return next(error); | ||
} | ||
|
||
if (err) { | ||
const error = new ErrorHandler(constants.ERRORS.DATABASE, { | ||
statusCode: 500, | ||
message: 'Mongo Error: Deletion Failed', | ||
errStack: err, | ||
}); | ||
if (err) { | ||
const error = new ErrorHandler(constants.ERRORS.DATABASE, { | ||
statusCode: 500, | ||
message: 'Mongo Error: Deletion Failed', | ||
errStack: err, | ||
}); | ||
|
||
return next(error); | ||
} | ||
return next(error); | ||
} | ||
|
||
return res.status(200).send({ | ||
message: 'Admin deleted successfully', | ||
}); | ||
} | ||
return res.status(200).send({ | ||
message: 'Admin deleted successfully', | ||
}); | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check failure
Code scanning / CodeQL
Database query built from user-controlled sources High