feat: User-Zuordnung für Sessions und Agents
- UserId-Feld zu SessionRecord und AgentRecord hinzugefügt - DB-Migration: user_id Spalte + bestehende Daten dem Admin zuweisen - Alle Endpoints filtern/prüfen nach UserId des eingeloggten Users - HttpContextExtensions.GetUserId() Helper für konsistenten Zugriff - Betrifft: Agent, Session, Chat, History, Workspace, Skill Endpoints - Sessions/Agents anderer User sind nicht sichtbar/zugreifbar
This commit is contained in:
1 parent
9a59ae686d
commit
7614141760
10 files changed
+123
-45
No files matched your search
@@ -6,6 +6,7 @@ using System.Net.Http;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Gott.Extensions;
|
||||
using Gott.Models;
|
||||
using Gott.Services;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
@@ -50,8 +51,9 @@ public static class ChatEndpoint
|
||||
}
|
||||
|
||||
// Agent aus Session auflösen
|
||||
var userId = req.HttpContext.GetUserId();
|
||||
var session = await db.GetSession(sessionId);
|
||||
if (session == null || string.IsNullOrEmpty(session.AgentId))
|
||||
if (session == null || session.UserId != userId || string.IsNullOrEmpty(session.AgentId))
|
||||
{
|
||||
res.StatusCode = 400;
|
||||
await res.WriteAsJsonAsync(new { error = "Kein Agent ausgewählt" });
|
||||
|
||||
Reference in new issue
Block a user