A simple file sharing site with an easy to use API and online panel.
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

16 satır
624B

  1. const config = require('config');
  2. const authenticate = require('./authenticate');
  3. const rateLimit = require('../rateLimit');
  4. const authenticateRequest = scope => (req, res, next) => {
  5. rateLimit(config.get('RateLimit.api.window'), config.get('RateLimit.api.max'))(req, res, async () => {
  6. const status = await authenticate(req, scope);
  7. if (status.authenticated) {
  8. if (status.permission) {
  9. next();
  10. } else res.status(403).json({message: 'Forbidden.'});
  11. } else res.status(401).json({message: 'Unauthorized.'});
  12. });
  13. };
  14. module.exports = authenticateRequest;