Skip to content
This repository has been archived by the owner on Jan 19, 2021. It is now read-only.

Commit

Permalink
Use origin instead of host
Browse files Browse the repository at this point in the history
  • Loading branch information
erayd committed Jan 28, 2020
1 parent 3c805b5 commit 55894d4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ chrome.runtime.onMessageExternal.addListener(function(request, sender) {
// update registry
registry[request.settings.tab.id] = {
otp: otp,
origin: request.settings.origin,
host: request.settings.host
};

Expand All @@ -92,7 +93,9 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
case "getToken":
if (
registry.hasOwnProperty(request.tabID) &&
registry[request.tabID].host === request.host
(registry[request.tabID].origin
? registry[request.tabID].origin === request.origin
: registry[request.tabID].host === request.host)
) {
let otp = registry[request.tabID].otp;
let response = { token: otp.generate() };
Expand Down
1 change: 1 addition & 0 deletions src/popup/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ function dispatchRequest() {
var request = {
action: "getToken",
tabID: tabs[0].id,
origin: new URL(tabs[0].url).origin,
host: new URL(tabs[0].url).hostname
};
// request new token
Expand Down

0 comments on commit 55894d4

Please sign in to comment.