Team-Eingang: /api/team mit Appwrite-JWT fuer alle Mitarbeiter, CORS-Header fuer Uploads

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Opus 5.5 committed 2026-10-01 19:23:57 +00:00
1 parent be65baff01
commit 772095ab19
7 files changed
+170 -26

No files matched your search

+1 -14
View File
@@ -1,5 +1,6 @@
import { Router } from 'express'
import { config } from '../../config.js'
import { appwriteAccountFromJwt } from '../../middleware/staffJwt.js'
import { createStaffPreviewToken } from '../../services/staffPreviewTokens.js'
import { resolveStaffAccount } from '../../services/staffAccount.js'
@@ -10,20 +11,6 @@ const router = Router()
* ueber /account geprueft (eine Sitzung ohne zweiten Faktor bekommt dort 401), aber ohne Label-Pflicht:
* jeder Mitarbeiter darf rueber, wie beim normalen Portal-Login.
*/
async function appwriteAccountFromJwt(req) {
const match = (req.get('Authorization') || '').match(/^Bearer\s+(.+)$/i)
if (!match) return null
const response = await fetch(`${config.appwrite.endpoint}/account`, {
headers: {
'Content-Type': 'application/json',
'X-Appwrite-Project': config.appwrite.projectId,
'X-Appwrite-JWT': match[1],
},
})
if (!response.ok) return null
return response.json()
}
router.post('/', async (req, res) => {
try {
const user = await appwriteAccountFromJwt(req)