Skip to content

Commit

Permalink
Migration ES6: DAOs
Browse files Browse the repository at this point in the history
Related #152
  • Loading branch information
UlisesGascon committed Jan 29, 2020
1 parent cad7959 commit d5b6976
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/data/profile-dao.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function ProfileDAO(db) {
this.updateUser = (userId, firstName, lastName, ssn, dob, address, bankAcc, bankRouting, callback) => {

// Create user document
var user = {};
const user = {};
if (firstName) {
user.firstName = firstName;
}
Expand Down
8 changes: 4 additions & 4 deletions app/data/user-dao.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function UserDAO(db) {
this.addUser = (userName, firstName, lastName, password, email, callback) => {

// Create user document
var user = {
const user = {
userName,
firstName,
lastName,
Expand Down Expand Up @@ -54,7 +54,7 @@ function UserDAO(db) {
return `${year}-${("0" + month).slice(-2)}-${("0" + day).slice(-2)}`
};

this.validateLogin = function(userName, password, callback) {
this.validateLogin = (userName, password, callback) => {

// Helper function to compare passwords
const comparePassword = (fromDB, fromUser) => {
Expand All @@ -75,13 +75,13 @@ function UserDAO(db) {
if (comparePassword(password, user.password)) {
callback(null, user);
} else {
var invalidPasswordError = new Error("Invalid password");
const invalidPasswordError = new Error("Invalid password");
// Set an extra field so we can distinguish this from a db error
invalidPasswordError.invalidPassword = true;
callback(invalidPasswordError, null);
}
} else {
var noSuchUserError = new Error("User: " + user + " does not exist");
const noSuchUserError = new Error("User: " + user + " does not exist");
// Set an extra field so we can distinguish this from a db error
noSuchUserError.noSuchUser = true;
callback(noSuchUserError, null);
Expand Down

0 comments on commit d5b6976

Please sign in to comment.