"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
require("core-js/modules/es.function.name.js");
var _passport = _interopRequireDefault(require("passport"));
var _util = _interopRequireDefault(require("util"));
/**
* Author: Michael Weibel <michael.weibel@gmail.com>
* License: MIT
*/
function StrategyMock(options, verify) {
this.name = 'mock';
this.passAuthentication = options.passAuthentication || true;
this.userId = options.userId || 123456;
this.verify = verify;
}
_util.default.inherits(StrategyMock, _passport.default.Strategy);
StrategyMock.prototype.authenticate = function authenticate(req) {
var _this = this;
if (this.passAuthentication) {
var user = {
id: this.userId
};
req.user = user;
this.verify(user, function (err, resident) {
if (err) {
_this.fail(err);
} else {
_this.success(resident);
}
});
} else {
this.fail('Unauthorized');
}
};
var _default = StrategyMock;
exports.default = _default;
//# sourceMappingURL=mock-passport-strategy.js.map