mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-01-18 18:56:25 +00:00
Merge pull request #328 from resin-io/fix/innacurate-invalid-2fa-code
Only throw "Invalid 2FA code" if we're sure that's the cause
This commit is contained in:
commit
4fc8b130f8
@ -56,9 +56,12 @@ limitations under the License.
|
||||
message: 'Two factor auth challenge:',
|
||||
name: 'code',
|
||||
type: 'input'
|
||||
}).then(resin.auth.twoFactor.challenge)["catch"](function() {
|
||||
}).then(resin.auth.twoFactor.challenge)["catch"](function(error) {
|
||||
return resin.auth.logout().then(function() {
|
||||
throw new Error('Invalid two factor authentication code');
|
||||
if (error.name === 'ResinRequestError' && error.statusCode === 401) {
|
||||
throw new Error('Invalid two factor authentication code');
|
||||
}
|
||||
throw error;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -44,9 +44,11 @@ exports.authenticate = (options) ->
|
||||
name: 'code'
|
||||
type: 'input'
|
||||
.then(resin.auth.twoFactor.challenge)
|
||||
.catch ->
|
||||
.catch (error) ->
|
||||
resin.auth.logout().then ->
|
||||
throw new Error('Invalid two factor authentication code')
|
||||
if error.name is 'ResinRequestError' and error.statusCode is 401
|
||||
throw new Error('Invalid two factor authentication code')
|
||||
throw error
|
||||
|
||||
exports.askLoginType = ->
|
||||
return form.ask
|
||||
|
Loading…
Reference in New Issue
Block a user