Merge pull request #66 from j-ed/patch-1

show more detailed u2f device registration error messages
This commit is contained in:
Christoph Wurst 2017-10-10 23:02:11 +02:00 коммит произвёл GitHub
Родитель f2d746ba7c 44f742492f
Коммит de69230b5d
1 изменённых файлов: 23 добавлений и 3 удалений

Просмотреть файл

@ -256,9 +256,29 @@
u2f.register(url, [req], sigs, function (data) {
if (data.errorCode && data.errorCode !== 0) {
$('.utf-register-info').slideUp();
reject(new Error(t('twofactor_u2f', 'U2F device registration failed (error code {errorCode})', {
errorCode: data.errorCode
})));
// https://developers.yubico.com/U2F/Libraries/Client_error_codes.html
switch(data.errorCode) {
case 4:
// 4 - DEVICE_INELIGIBLE
reject(new Error(t('twofactor_u2f', 'U2F device is already registered (error code {errorCode})', {
errorCode: data.errorCode
})));
break;
case 5:
// 5 - TIMEOUT
reject(new Error(t('twofactor_u2f', 'U2F device registration timeout reached (error code {errorCode})', {
errorCode: data.errorCode
})));
break;
default:
// 1 - OTHER_ERROR
// 2 - BAD_REQUEST
// 3 - CONFIGURATION_UNSUPPORTED
reject(new Error(t('twofactor_u2f', 'U2F device registration failed (error code {errorCode})', {
errorCode: data.errorCode
})));
}
return;
}
resolve(data);