feat(web): restore candidate notice on home for logged-in users
This commit is contained in:
1 parent
0518397492
commit
ff88e91640
5 files changed
+39
-12
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { session, visit } from "./api.js";
|
||||
import { disposeAll } from "./charts.js";
|
||||
import { onRoute, parseLocation, startRouter } from "./router.js";
|
||||
import { canAccessProtected, setSession } from "./session.js";
|
||||
import { renderCandidates } from "./views/candidates.js";
|
||||
import { renderFans } from "./views/fans.js";
|
||||
import { renderHome } from "./views/home.js";
|
||||
@@ -51,12 +52,6 @@ function renderLegacyRank(root, context) {
|
||||
: renderVideos(root, context);
|
||||
}
|
||||
|
||||
let authState = { authEnabled: false, authenticated: true };
|
||||
|
||||
function canAccessProtected() {
|
||||
return !authState.authEnabled || authState.authenticated;
|
||||
}
|
||||
|
||||
function requireAuth() {
|
||||
if (canAccessProtected()) return true;
|
||||
const { path, query } = parseLocation();
|
||||
@@ -152,10 +147,7 @@ async function boot() {
|
||||
const banner = document.querySelector("#preview-banner");
|
||||
try {
|
||||
const data = await session();
|
||||
authState = {
|
||||
authEnabled: Boolean(data?.auth_enabled),
|
||||
authenticated: data?.authenticated !== false,
|
||||
};
|
||||
setSession(data);
|
||||
if (data?.preview) {
|
||||
banner.hidden = false;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user