Skip to content

Commit

Permalink
Update passport.js
Browse files Browse the repository at this point in the history
FIXES: SQLInjection Vulnerability in Login
  • Loading branch information
Nymokrit committed Jan 28, 2021
1 parent 6de6922 commit 5c13c6a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/config/passport.js
Expand Up @@ -25,7 +25,7 @@ module.exports = function (passport) {

// used to deserialize the user
passport.deserializeUser(function (id, done) {
connection.query("select * from users where id = " + id, function (err, rows) {
connection.query("select * from users where id = ?", [id], function (err, rows) {
done(err, rows[0]);
});
});
Expand All @@ -46,7 +46,7 @@ module.exports = function (passport) {
function (req, email, password, done) {
// find a user whose email is the same as the forms email
// we are checking to see if the user trying to login already exists
connection.query("select * from users where email = '" + email + "'", function (err, rows) {
connection.query("select * from users where email = ?" + [email], function (err, rows) {
if (err) {return done(err);}
if (rows.length) {
req.signUpMessage = 'Diese e-Mail ist bei uns bereits registriert';
Expand Down Expand Up @@ -84,7 +84,7 @@ module.exports = function (passport) {
passReqToCallback: true // allows us to pass back the entire request to the callback
},
function (req, email, password, done) { // callback with email and password from our form
connection.query("SELECT * FROM `users` WHERE `email` = '" + email + "'", function (err, rows) {
connection.query("SELECT * FROM `users` WHERE `email` = ?", [email], function (err, rows) {
if (err) {return done(err);}

if (!rows.length) {
Expand Down

0 comments on commit 5c13c6a

Please sign in to comment.