Skip to content

Commit

Permalink
refactoring auth example
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Apr 11, 2012
1 parent 91eb275 commit 7048be2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion examples/auth/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,15 @@ var users = {

// Used to generate a hash of the plain-text password + salt
function hash(msg, key) {
return crypto.createHmac('sha256', key).update(msg).digest('hex');
return crypto
.createHmac('sha256', key)
.update(msg)
.digest('hex');
}

// Authenticate using our plain-object database of doom!
function authenticate(name, pass, fn) {
console.log('authenticating %s:%s', name, pass);
var user = users[name];
// query the db for the given username
if (!user) return fn(new Error('cannot find user'));
Expand Down

0 comments on commit 7048be2

Please sign in to comment.