Home / Function/ andRestrictToSelf() — express Function Reference

andRestrictToSelf() — express Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  96915432_ae7c_6c54_3271_57d43730c241["andRestrictToSelf()"]
  afb8616c_d315_1619_1936_54fa1bc1f161["index.js"]
  96915432_ae7c_6c54_3271_57d43730c241 -->|defined in| afb8616c_d315_1619_1936_54fa1bc1f161
  style 96915432_ae7c_6c54_3271_57d43730c241 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

examples/route-middleware/index.js lines 36–48

function andRestrictToSelf(req, res, next) {
  // If our authenticated user is the user we are viewing
  // then everything is fine :)
  if (req.authenticatedUser.id === req.user.id) {
    next();
  } else {
    // You may want to implement specific exceptions
    // such as UnauthorizedError or similar so that you
    // can handle these can be special-cased in an error handler
    // (view ./examples/pages for this)
    next(new Error('Unauthorized'));
  }
}

Domain

Subdomains

Frequently Asked Questions

What does andRestrictToSelf() do?
andRestrictToSelf() is a function in the express codebase, defined in examples/route-middleware/index.js.
Where is andRestrictToSelf() defined?
andRestrictToSelf() is defined in examples/route-middleware/index.js at line 36.

Analyze Your Own Codebase

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

Try Supermodel Free