feat: User-Berechtigungen für Agent-Erstellung und CLI-Nutzung
- Neue Felder CanCreateAgents und CanUseCli im UserRecord (Default: true) - DB-Migration mit Abwärtskompatibilität (bestehende User behalten alle Rechte) - Admin-UI: Checkboxen für beide Berechtigungen pro User - AgentEndpoint: Prüfung auf CanCreateAgents beim Erstellen - ChatEndpoint: CLI-Fallback nur wenn CanUseCli erlaubt - Frontend: Neuer-Agent-Button und Agent-Page bei fehlender Berechtigung gesperrt - Chat: Proaktive Warnung wenn kein API-Key und keine CLI-Berechtigung - Bug Fix: is_public fehlte im Agent-INSERT (Public Agents erst nach erneutem Speichern sichtbar) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
500c00f948
commit
f03fbd298e
13 files changed
+100
-16
No files matched your search
@@ -243,6 +243,15 @@ public static class ChatEndpoint
|
||||
// Kein API-Key → Claude CLI als Fallback verwenden
|
||||
if (string.IsNullOrEmpty(anthropicToken))
|
||||
{
|
||||
// CLI-Berechtigung prüfen
|
||||
var chatUser = await db.GetUser(userId);
|
||||
if (chatUser != null && !chatUser.CanUseCli && !chatUser.IsAdmin)
|
||||
{
|
||||
await SseHelper.TryWriteSse(res, "error", new { error = "Kein API-Key zugewiesen und keine CLI-Berechtigung. Bitte einen Key zuweisen." }, sseCt);
|
||||
await SseHelper.TryWriteSse(res, "done", new { chainId = ctx.ChainId }, sseCt);
|
||||
return;
|
||||
}
|
||||
|
||||
if (anthropic.IsCliAvailable)
|
||||
{
|
||||
await anthropic.StreamChatViaCli(res, ctx.ModelId, ctx.SystemPrompt, messages, ctx.ChainId, workspace: ctx.Workspace, allowUserChoice: ctx.Agent?.AllowUserChoice ?? true, planMode: body.PlanMode, webSearch: !string.IsNullOrEmpty(ctx.WebSearchVersion), sessionId: sessionId, agentId: ctx.AgentId, remoteMgr: remoteMgr, unityMcpUrl: ctx.Session?.UnityMcpUrl, unityMcpToken: ctx.Session?.UnityMcpToken, workCt: workCt, sseCt: sseCt);
|
||||
|
||||
Reference in new issue
Block a user