Preview: Bereitschaft aus echtem Zustand statt hasPreview (Standardwert false sperrte Previews)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
04b45e4207
commit
c37dd49b05
4 files changed
+87
-14
No files matched your search
@@ -2,6 +2,7 @@ import { Router } from 'express'
|
||||
import { config } from '../../config.js'
|
||||
import { requireAppwriteStaff } from '../../middleware/appwriteStaff.js'
|
||||
import { listDocuments, Query } from '../../services/appwriteAdmin.js'
|
||||
import { isPreviewProjectReady } from '../../services/previewReadiness.js'
|
||||
import { createStaffPreviewToken } from '../../services/staffPreviewTokens.js'
|
||||
|
||||
const router = Router()
|
||||
@@ -10,13 +11,6 @@ function isStaffAdmin(user) {
|
||||
return (user?.labels || []).includes('admin')
|
||||
}
|
||||
|
||||
function isPreviewProjectReady(project) {
|
||||
if (!project) return false
|
||||
if (project.hasPreview === false) return false
|
||||
const status = (project.provisioningStatus || project.status || '').toLowerCase()
|
||||
return ['ready', 'deployed'].includes(status)
|
||||
}
|
||||
|
||||
function safePreviewUrl(url) {
|
||||
try {
|
||||
const parsed = new URL(String(url || ''))
|
||||
|
||||
@@ -26,6 +26,7 @@ import {
|
||||
previewSessionCookieOptions,
|
||||
verifyPreviewSessionToken,
|
||||
} from '../services/previewSession.js'
|
||||
import { isPreviewProjectReady } from '../services/previewReadiness.js'
|
||||
import { consumeStaffPreviewToken } from '../services/staffPreviewTokens.js'
|
||||
import { resolveStaffAccount } from '../services/staffAccount.js'
|
||||
import { MFA_COOKIE, MFA_TTL_MS, resendStaffMfa, startStaffMfa, verifyStaffMfa } from '../services/staffMfa.js'
|
||||
@@ -120,13 +121,6 @@ async function resolveSessionCustomer(session) {
|
||||
return customer
|
||||
}
|
||||
|
||||
function isPreviewProjectReady(project) {
|
||||
if (!project) return false
|
||||
if (project.hasPreview === false) return false
|
||||
const status = (project.provisioningStatus || project.status || '').toLowerCase()
|
||||
return ['ready', 'deployed'].includes(status)
|
||||
}
|
||||
|
||||
function isAdminSession(session) {
|
||||
return session?.role === 'admin' || (session?.labels || []).includes('admin')
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Ist die Vorschau eines Projekts freigabebereit? Wird von /api/auth/preview-access und
|
||||
* dem Staff-Preview-Open genutzt.
|
||||
*
|
||||
* `hasPreview` wird bewusst NICHT mehr ausgewertet: Das Appwrite-Attribut wurde am 22.07.2026
|
||||
* mit Standardwert false angelegt und wird seit Commit 617d463 nicht mehr gepflegt, daher
|
||||
* waere jedes neuere Projekt faelschlich gesperrt. Massgeblich ist der echte Zustand.
|
||||
*/
|
||||
export function isPreviewProjectReady(project) {
|
||||
if (!project) return false
|
||||
if (!String(project.subdomain || '').trim()) return false
|
||||
if (project.previewMode === 'off') return false
|
||||
if (project.projectType === 'repo' || project.projectType === 'project') return false
|
||||
const status = String(project.provisioningStatus || project.status || '').toLowerCase()
|
||||
return ['ready', 'deployed'].includes(status)
|
||||
}
|
||||
Reference in new issue
Block a user