Skip to content

Commit

Permalink
build fixes, removed addUser method, since it's not av. yet.
Browse files Browse the repository at this point in the history
  • Loading branch information
idangozlan committed Jun 25, 2017
1 parent 149fab9 commit dcc1a7d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 27 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lib
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"prepublish": "npm run build"
},
"main": "lib/index.js",
"version": "1.0.0",
"version": "1.0.3",
"description": "Verdaccio module to authenticate users via Bitbucket",
"keywords": [
"sinopia",
Expand Down
32 changes: 6 additions & 26 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,18 +165,13 @@ function Auth(config, stuff) {
* Logs a given error
* This is private method running in context of Auth object
*
* @param {object} logger
* @param {string} err
* @param {string} username
* @access private
*/
const logError = (err, username) => {
this.logger.warn({
username,
errMsg: err.message,
code: err.code,
},
'@{code}, user: @{username}, BITBUCKER error: @{errMsg}',
);
const logError = (logger, err, username) => {
logger.warn(`${err.code}, user: ${username}, Bitbucket API adaptor error: ${err.message}`);
};

/**
Expand All @@ -188,7 +183,7 @@ const logError = (err, username) => {
* @param {Function} done - success or error callback
* @access public
*/
Auth.prototype.authenticate = (username, password, done) => {
Auth.prototype.authenticate = function authenticate(username, password, done) {
const credentials = {
username: decodeUsernameToEmail(username),
password,
Expand All @@ -208,13 +203,13 @@ Auth.prototype.authenticate = (username, password, done) => {

return this.bitbucket.user().get((err) => {
if (err) {
logError.call(this, err, username);
logError(this.logger, err, username);
return done(err, false);
}

return this.bitbucket.user().privileges((err2, privileges) => {
if (err2) {
logError.call(this, err2, username);
logError(this.logger, err2, username);
return done(err2, false);
}

Expand All @@ -239,19 +234,4 @@ Auth.prototype.authenticate = (username, password, done) => {
});
};

/**
* Adding a new user
* Currently we do not support adding bitbucket users via private npm registry
* So this method is simplay alias for Auth.authenticate()
*
* @see {@link Auth#authenticate}
* @param {string} username - user name to add
* @param {string} password - user password
* @param done - success or failure callback
* @access public
*/
Auth.prototype.add_user = (username, password, done) => {
done('Add User feature is not supported yet.');
};

module.exports = Auth;

0 comments on commit dcc1a7d

Please sign in to comment.