try refactor auth

This commit is contained in:
overcuriousity
2025-07-24 00:26:01 +02:00
parent 0ac31484d5
commit 32fca8a06f
10 changed files with 236 additions and 135 deletions

View File

@@ -150,24 +150,12 @@ const sortedTags = Object.entries(tagFrequency)
let isTagCloudExpanded = false;
// Check authentication status and show/hide AI button
async function checkAuthAndShowAIButton() {
try {
const response = await fetch('/api/auth/status');
const data = await response.json();
// Show AI button if authentication is not required OR if user is authenticated
if (!data.authRequired || data.authenticated) {
if (aiViewToggle) {
aiViewToggle.style.display = 'inline-flex';
}
}
} catch (error) {
console.log('Auth check failed, AI button remains hidden');
}
async function initAIButton() {
await showIfAuthenticated('#ai-view-toggle');
}
// Call auth check on page load
checkAuthAndShowAIButton();
initAIButton();
// Initialize tag cloud state
function initTagCloud() {