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

Commit

Permalink
Merge pull request #3454 from mozilla-services/2939-no-shots-auth
Browse files Browse the repository at this point in the history
Fix #2939, avoid infinite refresh loop on shots page
  • Loading branch information
ianb authored Sep 1, 2017
2 parents 4d41d17 + 546cf23 commit 7b52cbc
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions server/src/pages/shotindex/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const sendEvent = require("../../browser-send-event.js");
const page = require("./page").page;
const { AbstractShot } = require("../../../shared/shot");

const TEN_SECONDS = 10 * 1000;
const FIVE_SECONDS = 5 * 1000;

let model;

Expand All @@ -27,17 +27,21 @@ exports.launch = function(m) {
return;
}
if (window.wantsauth) {
if (window.wantsauth.getAuthData()) {
location.reload();
} else {
let authTimeout = setTimeout(() => {
location.pathname = "";
}, TEN_SECONDS);
window.wantsauth.addAuthDataListener((data) => {
clearTimeout(authTimeout);
location.reload();
});
if (window.wantsauth.getAuthData() && location.search.indexOf("reloaded") === -1) {
location.search = "reloaded";
return;
}
let authTimeout = setTimeout(() => {
// eslint-disable-next-line no-global-assign
location = location.origin;
}, FIVE_SECONDS);
window.wantsauth.addAuthDataListener((data) => {
if (location.search.indexOf("reloaded") > -1) {
return;
}
clearTimeout(authTimeout);
location.search = "reloaded";
});
}
};

Expand Down

0 comments on commit 7b52cbc

Please # to comment.