Skip to content

Commit

Permalink
chapter 05: adding authentication function that violates SRP, open cl…
Browse files Browse the repository at this point in the history
…ose andependency inversion among others
  • Loading branch information
devcorpio committed Mar 31, 2019
1 parent 9bea4e9 commit 7043373
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions chapter-05-the-dependency-inversion-principle/authentication.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function authentication(connection) {
function checkCredentials(username, password) {
const user = connection.fetchAssoc(
'SELECT * FROM users WHERE username = ?',
[username]
);

if (user === null) {
new Error('User not found');
}

//validate password...
}

return {
checkCredentials,
};
}

module.exports = authentication;

0 comments on commit 7043373

Please sign in to comment.