Kundenansicht: Einmal-Link aus dem Ticketsystem, Sitzung und Preview-Zugang fuer 2 Stunden, Protokoll

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Opus 5.5 committed 2026-10-01 19:27:21 +00:00
1 parent fdf594706d
commit 1cd776a2ee
10 files changed
+277 -7

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
import { config } from '../config.js'
import { getDocument, getPortalAccessByCustomerId } from './appwriteAdmin.js'
/**
* Portal-Zugang eines Kunden fuer das Ticketsystem: hasAccess wie beim Login (customers.portalAccessEnabled und ein
* freigeschaltetes customerPortalAccess-Dokument), dazu der letzte Login. customer = null bei unbekanntem Kunden.
*/
export async function getPortalAccessStatus(customerId) {
const customer = await getDocument(config.collections.customers, customerId).catch((err) => {
if (err.status === 404) return null
throw err
})
if (!customer) return { customer: null, hasAccess: false, lastLoginAt: null }
const access = await getPortalAccessByCustomerId(customer.$id)
return {
customer,
hasAccess: Boolean(customer.portalAccessEnabled && access?.enabled),
lastLoginAt: access?.lastLoginAt || null,
}
}