Skip to content

Commit

Permalink
If call to account.json fails - show sign in button
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukewh committed Dec 7, 2023
1 parent add7273 commit 5547c0c
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions static/js/base/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
var navAccountContainer = document.querySelector(".js-nav-account");

if (navAccountContainer) {
var notAuthenticatedMenu = navAccountContainer.querySelector(
".js-nav-account--notauthenticated"
);
var authenticatedMenu = navAccountContainer.querySelector(
".js-nav-account--authenticated"
);

fetch("/account.json")
.then((response) => response.json())
.then((data) => {
var notAuthenticatedMenu = navAccountContainer.querySelector(
".js-nav-account--notauthenticated"
);
var authenticatedMenu = navAccountContainer.querySelector(
".js-nav-account--authenticated"
);

if (data.publisher) {
var displayName = navAccountContainer.querySelector(
".js-account--name"
Expand All @@ -30,5 +30,9 @@ if (navAccountContainer) {
notAuthenticatedMenu.classList.remove("u-hide");
authenticatedMenu.classList.add("u-hide");
}
});
}).
catch((e) => {
notAuthenticatedMenu.classList.remove("u-hide");
authenticatedMenu.classList.add("u-hide");
});;
}

0 comments on commit 5547c0c

Please sign in to comment.