feat: fix calculation of token invalidation #3077
No reviewers
Labels
No Label
area/internal-code
changes requested
confirmed
dependencies
duplicate
good first issue
help wanted
hosting
invalid
kind/bug
kind/feature
question
wontfix
No Milestone
No project
No Assignees
3 Participants
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: vikunja/frontend#3077
Loading…
Reference in New Issue
No description provided.
Delete Branch "dpschen/frontend:feature/fix-calculation-of-token-invalidation"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hi dpschen!
Thank you for creating a PR!
I've deployed the changes of this PR on a preview environment under this URL: https://3077-feature-fix-calculation-of-token--vikunja-frontend-preview.netlify.app
You can use this url to view the changes live and test them out.
You will need to manually connect this to an api running somehwere. The easiest to use is https://try.vikunja.io/.
Have a nice day!
df95f1ef33
tobf957319f9
@ -25,3 +25,3 @@
}
const expiresIn = (userInfo.value !== null ? userInfo.value.exp : 0) - new Date().valueOf() / MILLISECONDS_A_HOUR
const nowInSeconds = new Date().getTime() / MILLISECONDS_A_SECOND
MILLISECONDS_A_HOUR
is wrong. It was originally the value1000
which isMILLISECONDS_A_HOUR
.Why do we need that constant anyway if we're only dealing with milliseconds -> seconds here?
1000
wouldn't explain why we divide through it.The constant has the explanation in its name. but the real reason for me is mostly to be consequent. One should probably not touch the code if one doesn't know the metric 'milli'.
That makes sense.
@ -29,3 +32,3 @@
// If the token expiry is negative, it is already expired and we have no choice but to redirect
// the user to the login page
if (expiresIn < 0) {
if (expiresIn <= 0) {
I'm unsure about this. Even though very unlikely I understood this as we allow tokens that are only valid another second. Would probably be best to have some buffer here.
I think it does not matter much to have that buffer but it's fine to leave it in.
@ -26,2 +26,3 @@
const expiresIn = (userInfo.value !== null ? userInfo.value.exp : 0) - new Date().valueOf() / MILLISECONDS_A_HOUR
const nowInSeconds = new Date().getTime() / MILLISECONDS_A_SECOND
const expiresIn = userInfo.value !== null
I tried to make this part easier to understand.