Skip to content

Commit

Permalink
Change user queries so passwords are not displayed on requests
Browse files Browse the repository at this point in the history
  • Loading branch information
CampbellDocherty committed Apr 17, 2020
1 parent f0a1827 commit c501d6f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions model/user-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function resultRows(result){
function addUser(username, hashedPassword) {
return db
.query(
"INSERT INTO users(username, password) VALUES (($1), ($2)) RETURNING *",
"INSERT INTO users(username, password) VALUES (($1), ($2)) RETURNING id, username",
[
username,
hashedPassword
Expand All @@ -23,20 +23,20 @@ function addUser(username, hashedPassword) {
//Gets a single user by id
function getUser(userId) {
return db
.query("SELECT * FROM users WHERE id=($1)", [userId])
.query("SELECT id, username FROM users WHERE id=($1)", [userId])
.then(resultRowsZero);
}

//Gets a single user by username
function getUserByName(username) {
return db
.query("SELECT * FROM users WHERE username=($1)", [username])
.query("SELECT id, username FROM users WHERE username=($1)", [username])
.then(resultRowsZero);
}

//Gets all users
function getEveryUser() {
return db.query("SELECT * from users").then(resultRows);
return db.query("SELECT id, username FROM users").then(resultRows);
}

module.exports = { addUser, getUser, getEveryUser, getUserByName };

0 comments on commit c501d6f

Please sign in to comment.