Portal-Login: Mitarbeiter kommen ins Admin-Panel, Admin-Label bleibt WOMS-Rolle

Bisher liess /api/auth/login nur Appwrite-User mit dem Label "admin" in die
Admin-Ansicht; alle anderen fielen in den Kunden-Login und bekamen "Kein
Kundenkonto fuer diesen Login gefunden". Mitarbeiter ohne Admin-Haken (z.B.
nico@webklar.com) kamen damit nicht auf /admin.html.

Jetzt gilt: Wer in der employees-Collection steht, ist Backoffice-Nutzer. Das
Label "admin" ist nur noch die WOMS-Adminrolle (Mitarbeiterverwaltung) und wird
als isAdmin-Flag in der Portal-Session bzw. in den Preview-Token-Labels
mitgefuehrt - inklusive "Als Kunde ansehen" und zurueck.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Claude
2026-08-11 18:26:59 +00:00
parent ac264dc9ba
commit 87aa7a7821
3 changed files with 69 additions and 14 deletions

View File

@@ -162,6 +162,24 @@ export async function getCustomerByEmail(email) {
return docs[0] || null
}
export async function getEmployeeByUserId(userId) {
if (!userId) return null
const docs = await listDocuments(config.collections.employees, [
Query.equal('userId', userId),
Query.limit(1),
])
return docs[0] || null
}
export async function getEmployeeByEmail(email) {
if (!email) return null
const docs = await listDocuments(config.collections.employees, [
Query.equal('email', email.trim().toLowerCase()),
Query.limit(1),
])
return docs[0] || null
}
export async function getPortalAccessByCustomerId(customerId) {
const docs = await listDocuments(config.collections.customerPortalAccess, [
Query.equal('customerId', customerId),