Skip to content

Commit

Permalink
Merge pull request #800 from TokenScript/fix/deny-connection
Browse files Browse the repository at this point in the history
enable cookie storage for when user denies connection to outlet
  • Loading branch information
nicktaras authored Aug 17, 2023
2 parents 7c73828 + 05c7d5f commit 1aabf45
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/outlet/whitelist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,25 +174,21 @@ export class Whitelist {
resolve()
})

document.getElementById('tn-access-deny').addEventListener('click', () => {
const updateWhistList = () => {
if (this.storedWhitelist[origin]) delete this.storedWhitelist[origin]

this.saveWhitelist()

// set for 10 seconds so the following send token requests don't re-open
// the dialog multiple times when the user has declined connection.
// adjust if needed to find the best timing, which should be the approx duration of
// the time needed to ignore request for same site issuer dialog requests
// and the time a user would come back to load the tokens again should
// the decline by accident.
createCookie('tn-user-denied-access-to-connection', true, 10)
}

// store cookie whilst allowing error to be thrown.
try {
reject(new Error('USER_ABORT'))
} catch (e) {
reject(new Error('USER_ABORT'))
}
document.getElementById('tn-access-deny').addEventListener('click', () => {
updateWhistList()
reject(new Error('USER_ABORT'))
})

this.showWhitelistCallback()
Expand Down

0 comments on commit 1aabf45

Please sign in to comment.