fixed YubiKey errors display

pull/1631/head
antelle 2020-11-11 23:08:08 +01:00
parent 9c18e2877b
commit 49d46cfedc
No known key found for this signature in database
GPG Key ID: 63C9777AAB7C563C
2 changed files with 15 additions and 3 deletions

View File

@ -686,5 +686,6 @@
"yubiKeyTouchRequestedHeader": "Touch your YubiKey",
"yubiKeyTouchRequestedBody": "Please touch your YubiKey with serial number {}",
"yubiKeyDisabledErrorHeader": "USB is disabled",
"yubiKeyDisabledErrorBody": "YubiKey is required to open this file, please enable USB devices in settings."
"yubiKeyDisabledErrorBody": "YubiKey is required to open this file, please enable USB devices in settings.",
"yubiKeyErrorWithCode": "YubiKey error, code {}."
}

View File

@ -691,7 +691,7 @@ class OpenView extends View {
Alerts.error({
header: Locale.openError,
body: Locale.openErrorDescription,
pre: err.toString()
pre: this.errorToString(err)
});
}
} else {
@ -1027,7 +1027,7 @@ class OpenView extends View {
Alerts.error({
header: Locale.openError,
body: Locale.openErrorDescription,
pre: err.toString()
pre: this.errorToString(err)
});
}
this.otpDevice = null;
@ -1071,6 +1071,17 @@ class OpenView extends View {
view: chalRespView
});
}
errorToString(err) {
const str = err.toString();
if (str !== {}.toString()) {
return str;
}
if (err.ykError && err.code) {
return Locale.yubiKeyErrorWithCode.replace('{}', err.code);
}
return undefined;
}
}
export { OpenView };