Skip to content

Commit

Permalink
profile: better explanation on OTP (#24)
Browse files Browse the repository at this point in the history
Use the defaut OTP explanation everywhere except when the context is
"OTP-aware" (like when setting double-authentication)

PR-URL: npm#24
Credit: @jdeniau
Reviewed-By: @zkat
  • Loading branch information
jdeniau authored and zkat committed Jul 20, 2018
1 parent a9ac871 commit 21cf0ab
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/auth/legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function login (conf) {
})
.catch((err) => {
if (err.code !== 'EOTP') throw err
return read.otp('Authenticator provided OTP:').then((otp) => {
return read.otp('Enter one-time password from your authenticator app: ').then((otp) => {
conf.auth.otp = otp
const u = conf.creds.username
const p = conf.creds.password
Expand Down
4 changes: 2 additions & 2 deletions lib/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ function set (args) {
newUser[prop] = value
return profile.set(newUser, conf).catch((err) => {
if (err.code !== 'EOTP') throw err
return readUserInfo.otp('Enter OTP: ').then((otp) => {
return readUserInfo.otp().then((otp) => {
conf.auth.otp = otp
return profile.set(newUser, conf)
})
Expand Down Expand Up @@ -262,7 +262,7 @@ function enable2fa (args) {
return pulseTillDone.withPromise(profile.set({tfa: {password, mode: 'disable'}}, conf))
} else {
if (conf.auth.otp) return
return readUserInfo.otp('Enter OTP: ').then((otp) => {
return readUserInfo.otp('Enter one-time password from your authenticator app: ').then((otp) => {
conf.auth.otp = otp
})
}
Expand Down
4 changes: 2 additions & 2 deletions lib/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ function rm (args) {
return profile.removeToken(key, conf).catch((ex) => {
if (ex.code !== 'EOTP') throw ex
log.info('token', 'failed because revoking this token requires OTP')
return readUserInfo.otp('Authenticator provided OTP:').then((otp) => {
return readUserInfo.otp().then((otp) => {
conf.auth.otp = otp
return profile.removeToken(key, conf)
})
Expand Down Expand Up @@ -192,7 +192,7 @@ function create (args) {
return profile.createToken(password, readonly, validCIDR, conf).catch((ex) => {
if (ex.code !== 'EOTP') throw ex
log.info('token', 'failed because it requires OTP')
return readUserInfo.otp('Authenticator provided OTP:').then((otp) => {
return readUserInfo.otp().then((otp) => {
conf.auth.otp = otp
log.info('token', 'creating with OTP')
return pulseTillDone.withPromise(profile.createToken(password, readonly, validCIDR, conf))
Expand Down

0 comments on commit 21cf0ab

Please sign in to comment.