added an error when usb is disabled

This commit is contained in:
antelle 2020-06-05 20:37:13 +02:00
parent eab683ec71
commit c1d354a6fb
No known key found for this signature in database
GPG Key ID: 63C9777AAB7C563C
2 changed files with 20 additions and 2 deletions

View File

@ -6,6 +6,7 @@ import { Alerts } from 'comp/ui/alerts';
import { Locale } from 'util/locale';
import { Timeouts } from 'const/timeouts';
import { Launcher } from 'comp/launcher';
import { AppSettingsModel } from 'models/app-settings-model';
const logger = new Logger('chal-resp');
@ -32,6 +33,21 @@ const ChalRespCalculator = {
return resolve(Buffer.from(respFromCache, 'hex'));
}
if (!AppSettingsModel.enableUsb) {
logger.debug('USB is disabled');
Alerts.error({
header: Locale.yubiKeyDisabledErrorHeader,
body: Locale.yubiKeyDisabledErrorBody,
complete() {
const err = new Error(Locale.yubiKeyDisabledErrorHeader);
err.userCanceled = true;
reject(err);
}
});
return;
}
logger.debug('Calculating ChalResp using a YubiKey', params);
this._calc(params, challenge, (err, response) => {
@ -105,7 +121,7 @@ const ChalRespCalculator = {
let deviceEnumerationTimer;
const onUsbDevicesChanged = () => {
if (UsbListener.attachedYubiKeys.length === 0) {
if (!UsbListener.attachedYubiKeys) {
return;
}
deviceEnumerationTimer = setTimeout(() => {

View File

@ -684,5 +684,7 @@
"yubiKeyNoKeyBody": "Please insert your YubiKey with serial number {}",
"yubiKeySlot": "slot",
"yubiKeyTouchRequestedHeader": "Touch your YubiKey",
"yubiKeyTouchRequestedBody": "Please touch your YubiKey with serial number {}"
"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."
}