Home / Function/ authenticate() — express Function Reference

authenticate() — express Function Reference

Architecture documentation for the authenticate() function in index.js from the express codebase.

Entity Profile

Dependency Diagram

graph TD
  c8ac278b_63c2_5ce0_786e_a48ccbc81fe5["authenticate()"]
  4924fa15_e8b8_3b95_7bfd_02ee7793dfc4["index.js"]
  c8ac278b_63c2_5ce0_786e_a48ccbc81fe5 -->|defined in| 4924fa15_e8b8_3b95_7bfd_02ee7793dfc4
  style c8ac278b_63c2_5ce0_786e_a48ccbc81fe5 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

examples/auth/index.js lines 60–73

function authenticate(name, pass, fn) {
  if (!module.parent) console.log('authenticating %s:%s', name, pass);
  var user = users[name];
  // query the db for the given username
  if (!user) return fn(null, null)
  // apply the same algorithm to the POSTed password, applying
  // the hash against the pass / salt, if there is a match we
  // found the user
  hash({ password: pass, salt: user.salt }, function (err, pass, salt, hash) {
    if (err) return fn(err);
    if (hash === user.hash) return fn(null, user)
    fn(null, null)
  });
}

Domain

Subdomains

Frequently Asked Questions

What does authenticate() do?
authenticate() is a function in the express codebase, defined in examples/auth/index.js.
Where is authenticate() defined?
authenticate() is defined in examples/auth/index.js at line 60.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free