diff --git a/docs/MONETIZATION.md b/docs/MONETIZATION.md index 5e32a3b..7408e2d 100644 --- a/docs/MONETIZATION.md +++ b/docs/MONETIZATION.md @@ -42,7 +42,7 @@ - Keine externe Abhängigkeit, keine Lizenzkosten - Client löst SHA256-Challenge (Difficulty 4, ~1-3 Sek) - Bei Account-Erstellung (immer) -- Bei Anzeigen-Erstellung (immer) +- Bei Anzeigen-Erstellung (nur neue Accounts ohne bisherige Listings) - Bei Login (nur nach 3+ Fehlversuchen) - Implementierung: `js/services/pow-captcha.js`, `js/components/pow-captcha.js` diff --git a/js/components/pages/page-create.js b/js/components/pages/page-create.js index dc4fd40..57c7d51 100644 --- a/js/components/pages/page-create.js +++ b/js/components/pages/page-create.js @@ -28,6 +28,7 @@ class PageCreate extends HTMLElement { this.imagePreviews = [] this.categories = [] this.submitting = false + this.isNewAccount = true } loadDraft() { @@ -60,28 +61,56 @@ class PageCreate extends HTMLElement { this.hasDraft = !!localStorage.getItem(STORAGE_KEY) await this.loadCategories() + await this.checkAccountStatus() this.render() this.unsubscribe = i18n.subscribe(() => this.render()) } + async checkAccountStatus() { + try { + // Check if user has any published listings + const user = await auth.getUser() + if (user?.id) { + const listings = await directus.get('/items/listings', { + filter: { user_created: { _eq: user.id } }, + limit: 1 + }) + this.isNewAccount = !listings.data || listings.data.length === 0 + } + } catch (e) { + // Default to new account (show captcha) + this.isNewAccount = true + } + } + showLoginRequired() { + // Show login modal directly + const authModal = document.querySelector('auth-modal') + if (authModal) { + authModal.show('login') + authModal.addEventListener('login', async () => { + // After login, load the create page + this.hasDraft = !!localStorage.getItem(STORAGE_KEY) + await this.loadCategories() + this.render() + this.unsubscribe = i18n.subscribe(() => this.render()) + }, { once: true }) + authModal.addEventListener('close', () => { + // If closed without login, go back + if (!auth.isLoggedIn()) { + router.back() + } + }, { once: true }) + } + + // Show minimal loading state while modal is open this.innerHTML = /* html */`
${t('auth.loginRequired')}
${t('create.moneroHint')}
-