Skip to content

Commit

Permalink
remove timeDriftKey from sessionStorage on user logout
Browse files Browse the repository at this point in the history
  • Loading branch information
patrislav committed Nov 29, 2024
1 parent 024a18f commit d8223cd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/waas/src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ export class SequenceWaaS {
session.clear()
await this.waas.completeSignOut()
await this.deviceName.set(undefined)
updateTimeDrift(undefined)
}
}

Expand Down
10 changes: 9 additions & 1 deletion packages/waas/src/intents/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,15 @@ export function getTimeDrift() {
return timeDrift
}

export function updateTimeDrift(serverTime: Date) {
export function updateTimeDrift(serverTime?: Date) {
if (!serverTime) {
timeDrift = undefined
if (isSessionStorageAvailable()) {
window.sessionStorage.removeItem(timeDriftKey)
}
return
}

timeDrift = (getLocalTime() - serverTime.getTime()) / 1000
if (isSessionStorageAvailable()) {
window.sessionStorage.setItem(timeDriftKey, timeDrift.toString(10))
Expand Down

0 comments on commit d8223cd

Please sign in to comment.