mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-11-13 03:35:52 +01:00
26 lines
598 B
JavaScript
26 lines
598 B
JavaScript
'use strict';
|
|
|
|
module.exports = Plugin;
|
|
|
|
function Plugin(config) {
|
|
let self = Object.create(Plugin.prototype);
|
|
self._config = config;
|
|
return self;
|
|
}
|
|
|
|
// plugin is expected to be compatible with...
|
|
Plugin.prototype.verdaccio_version = '1.1.0';
|
|
|
|
Plugin.prototype.authenticate = function(user, password, cb) {
|
|
if (user !== this._config.accept_user) {
|
|
// delegate to next plugin
|
|
return cb(null, false);
|
|
}
|
|
if (password !== this._config.with_password) {
|
|
const err = Error('i don\'t like your password');
|
|
err.status = 403;
|
|
return cb(err);
|
|
}
|
|
return cb(null, [user]);
|
|
};
|