diff options
author | Rebecca Turner <me@re-becca.org> | 2018-03-23 04:23:24 +0300 |
---|---|---|
committer | Rebecca Turner <me@re-becca.org> | 2018-03-23 13:46:36 +0300 |
commit | 6d1aac42482a5fee7a38310ee2689050f95de056 (patch) | |
tree | 2edb3cdab3876945d2c25bdc922bf2a451c5560e /lib/auth | |
parent | c8146858d6e51411650ad4dc3bc5e294068ed1dc (diff) |
standardize
Diffstat (limited to 'lib/auth')
-rw-r--r-- | lib/auth/legacy.js | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/lib/auth/legacy.js b/lib/auth/legacy.js index 08de61bff..cb27a1edc 100644 --- a/lib/auth/legacy.js +++ b/lib/auth/legacy.js @@ -42,38 +42,38 @@ module.exports.login = (creds, registry, scope, cb) => { function login (conf) { return profile.login(openerPromise, loginPrompter, conf) - .catch((err) => { - if (err.code === 'EOTP') throw err - const u = conf.creds.username - const p = conf.creds.password - const e = conf.creds.email - if (!(u && p && e)) throw err - return profile.adduserCouch(u, e, p, conf) - }) - .catch((err) => { - if (err.code !== 'EOTP') throw err - return read.otp('Authenticator provided OTP:').then((otp) => { - conf.auth.otp = otp + .catch((err) => { + if (err.code === 'EOTP') throw err const u = conf.creds.username const p = conf.creds.password - return profile.loginCouch(u, p, conf) + const e = conf.creds.email + if (!(u && p && e)) throw err + return profile.adduserCouch(u, e, p, conf) }) - }).then((result) => { - const newCreds = {} - if (result && result.token) { - newCreds.token = result.token - } else { - newCreds.username = conf.creds.username - newCreds.password = conf.creds.password - newCreds.email = conf.creds.email - newCreds.alwaysAuth = npm.config.get('always-auth') - } + .catch((err) => { + if (err.code !== 'EOTP') throw err + return read.otp('Authenticator provided OTP:').then((otp) => { + conf.auth.otp = otp + const u = conf.creds.username + const p = conf.creds.password + return profile.loginCouch(u, p, conf) + }) + }).then((result) => { + const newCreds = {} + if (result && result.token) { + newCreds.token = result.token + } else { + newCreds.username = conf.creds.username + newCreds.password = conf.creds.password + newCreds.email = conf.creds.email + newCreds.alwaysAuth = npm.config.get('always-auth') + } - const usermsg = conf.creds.username ? ' user ' + conf.creds.username : '' - conf.log.info('login', 'Authorized' + usermsg) - const scopeMessage = conf.scope ? ' to scope ' + conf.scope : '' - const userout = conf.creds.username ? ' as ' + conf.creds.username : '' - output('Logged in%s%s on %s.', userout, scopeMessage, conf.registry) - return newCreds - }) + const usermsg = conf.creds.username ? ' user ' + conf.creds.username : '' + conf.log.info('login', 'Authorized' + usermsg) + const scopeMessage = conf.scope ? ' to scope ' + conf.scope : '' + const userout = conf.creds.username ? ' as ' + conf.creds.username : '' + output('Logged in%s%s on %s.', userout, scopeMessage, conf.registry) + return newCreds + }) } |