UNPKG

pip-services3-rpc-node

Version:
26 lines 907 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BasicAuthorizer = void 0; /** @module auth */ const _ = require('lodash'); const pip_services3_commons_node_1 = require("pip-services3-commons-node"); const HttpResponseSender_1 = require("../services/HttpResponseSender"); class BasicAuthorizer { anybody() { return (req, res, next) => { next(); }; } signed() { return (req, res, next) => { if (req.user == null) { HttpResponseSender_1.HttpResponseSender.sendError(req, res, new pip_services3_commons_node_1.UnauthorizedException(null, 'NOT_SIGNED', 'User must be signed in to perform this operation').withStatus(401)); } else { next(); } }; } } exports.BasicAuthorizer = BasicAuthorizer; //# sourceMappingURL=BasicAuthorizer.js.map