From 9279d0bf9feca69058217976489c833421b267f1 Mon Sep 17 00:00:00 2001 From: olfek <27283110+olfek@users.noreply.github.com> Date: Tue, 17 Sep 2024 00:58:57 +0100 Subject: [PATCH 1/3] [FIX] Seconds not properly prevented from being negative 0 - 61 + 60 < 0 59 - 120 + 60 < 0 https://github.com/Authenticator-Extension/Authenticator/blob/6511920bac98576e3c97fe2d213b23e9dc899422/src/store/Accounts.ts#L90 --- src/store/Accounts.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/store/Accounts.ts b/src/store/Accounts.ts index 57f6a47e..1744802e 100644 --- a/src/store/Accounts.ts +++ b/src/store/Accounts.ts @@ -90,7 +90,7 @@ export class Accounts implements Module { second += Number(UserSettings.items.offset) + 60; } - second = second % 60; + second = (second < 0) ? (60 - (second * -1) % 60) : (second % 60); state.second = second; let currentlyEncrypted = false; From 9480784187d02986abb8a089cda99babc7c00624 Mon Sep 17 00:00:00 2001 From: olfek <27283110+olfek@users.noreply.github.com> Date: Tue, 17 Sep 2024 10:15:28 +0100 Subject: [PATCH 2/3] Remove the now redundant `+ 60` --- src/store/Accounts.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/store/Accounts.ts b/src/store/Accounts.ts index 1744802e..55e2dd1c 100644 --- a/src/store/Accounts.ts +++ b/src/store/Accounts.ts @@ -87,7 +87,7 @@ export class Accounts implements Module { let second = new Date().getSeconds(); if (UserSettings.items.offset) { // prevent second from negative - second += Number(UserSettings.items.offset) + 60; + second += Number(UserSettings.items.offset); } second = (second < 0) ? (60 - (second * -1) % 60) : (second % 60); From 737ac3f2615552866f404060b41bd1d9e85a82c9 Mon Sep 17 00:00:00 2001 From: olfek <27283110+olfek@users.noreply.github.com> Date: Tue, 17 Sep 2024 15:25:17 +0100 Subject: [PATCH 3/3] Move comment --- src/store/Accounts.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/store/Accounts.ts b/src/store/Accounts.ts index 55e2dd1c..b7907b13 100644 --- a/src/store/Accounts.ts +++ b/src/store/Accounts.ts @@ -86,10 +86,10 @@ export class Accounts implements Module { updateCodes(state: AccountsState) { let second = new Date().getSeconds(); if (UserSettings.items.offset) { - // prevent second from negative second += Number(UserSettings.items.offset); } + // prevent second from negative second = (second < 0) ? (60 - (second * -1) % 60) : (second % 60); state.second = second;