Fix empty tokens handling

master
Andrew Gregory 2021-11-13 19:06:37 +08:00 committed by GitHub
parent 168dcd65e0
commit d9733ebd57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 8 deletions

View File

@ -7,13 +7,7 @@ const algos = {
"SHA1" :{sha:crypto.SHA1 ,retsz:20,blksz:64 }, "SHA1" :{sha:crypto.SHA1 ,retsz:20,blksz:64 },
}; };
var tokens = require("Storage").readJSON("authentiwatch.json", true) || [ var tokens = require("Storage").readJSON("authentiwatch.json", true) || [];
{algorithm:"SHA512",digits:8,period:60,secret:"aaaa aaaa aaaa aaaa",label:"AgAgAg"},
{algorithm:"SHA1",digits:6,period:30,secret:"bbbb bbbb bbbb bbbb",label:"BgBgBg"},
{algorithm:"SHA1",digits:8,period:-3,secret:"cccc cccc cccc cccc",label:"CgCgCg"},
{algorithm:"SHA1",digits:6,period:60,secret:"yyyy yyyy yyyy yyyy",label:"YgYgYg"},
{algorithm:"SHA1",digits:8,period:30,secret:"zzzz zzzz zzzz zzzz",label:"ZgZgZg"},
];
// QR Code Text // QR Code Text
// //
@ -223,7 +217,7 @@ function draw() {
function onTouch(zone, e) { function onTouch(zone, e) {
if (e) { if (e) {
var id = Math.floor((state.listy + (e.y - Bangle.appRect.y)) / tokenentryheight); var id = Math.floor((state.listy + (e.y - Bangle.appRect.y)) / tokenentryheight);
if (id == state.curtoken) { if (id == state.curtoken || tokens.length == 0) {
id = -1; id = -1;
} }
if (state.curtoken != id) { if (state.curtoken != id) {