Skip to content

Commit

Permalink
refactor: change flow of otplease
Browse files Browse the repository at this point in the history
  • Loading branch information
jumoel committed Jun 29, 2022
1 parent 0ce09f1 commit cf6be7c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/utils/otplease.js
Expand Up @@ -2,15 +2,21 @@ async function otplease (opts, fn) {
try {
return await fn(opts)
} catch (err) {
const readUserInfo = require('./read-user-info.js')
if (err.code !== 'EOTP' && (err.code !== 'E401' || !/one-time pass/.test(err.body))) {
if (!process.stdin.isTTY || !process.stdout.isTTY) {
throw err
} else if (!process.stdin.isTTY || !process.stdout.isTTY) {
}

if (err.code !== 'EOTP' && err.code !== 'E401') {
throw err
} else {
}

if (/one-time pass/.test(err.body)) {
const readUserInfo = require('./read-user-info.js')
const otp = await readUserInfo.otp('This operation requires a one-time password.\nEnter OTP:')
return await fn({ ...opts, otp })
}

throw err
}
}

Expand Down

0 comments on commit cf6be7c

Please sign in to comment.