feat: gate homepage entry buttons by login state
This commit is contained in:
1 parent
b124d070cb
commit
1d31de4796
1 file changed
+29
-2
+29
-2
@@ -1146,8 +1146,7 @@
|
|||||||
if (lightboxItem && lightboxItem.skillId) params.set("skill", lightboxItem.skillId);
|
if (lightboxItem && lightboxItem.skillId) params.set("skill", lightboxItem.skillId);
|
||||||
if (lightboxIndustry.name) params.set("industry", lightboxIndustry.name);
|
if (lightboxIndustry.name) params.set("industry", lightboxIndustry.name);
|
||||||
const target = "/generate" + (params.toString() ? "?" + params.toString() : "");
|
const target = "/generate" + (params.toString() ? "?" + params.toString() : "");
|
||||||
const loggedIn = !!localStorage.getItem("access_token");
|
goEntry(target);
|
||||||
window.location.href = loggedIn ? target : "/login/?redirect=" + encodeURIComponent(target);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeLightbox() {
|
function closeLightbox() {
|
||||||
@@ -1366,6 +1365,34 @@
|
|||||||
window.clearTimeout(resizeTimer);
|
window.clearTimeout(resizeTimer);
|
||||||
resizeTimer = window.setTimeout(measure, 120);
|
resizeTimer = window.setTimeout(measure, 120);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function isLoggedIn() {
|
||||||
|
return !!localStorage.getItem("access_token");
|
||||||
|
}
|
||||||
|
|
||||||
|
function goEntry(target) {
|
||||||
|
const dest = target || "/generate";
|
||||||
|
if (isLoggedIn()) {
|
||||||
|
window.location.href = dest;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const params = new URLSearchParams({ v: "20261107", redirect: dest });
|
||||||
|
window.location.href = "/login/?" + params.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
document.querySelectorAll("a.pill--login, a.pill--signup").forEach(function (link) {
|
||||||
|
link.addEventListener("click", function (event) {
|
||||||
|
event.preventDefault();
|
||||||
|
goEntry("/generate");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
document.querySelectorAll('a[href="/generate"]').forEach(function (link) {
|
||||||
|
link.addEventListener("click", function (event) {
|
||||||
|
event.preventDefault();
|
||||||
|
goEntry(link.getAttribute("href") || "/generate");
|
||||||
|
});
|
||||||
|
});
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in new issue
Block a user