Refactor EditorSession model to include token in props and update JSON parsing; simplify route handlers by removing JWT manager parameter

This commit is contained in:
Leon Bösche
2026-01-10 05:02:07 +01:00
parent 941d8bf736
commit 84c7ed0815
2 changed files with 8 additions and 5 deletions

View File

@@ -2,21 +2,24 @@ import 'package:equatable/equatable.dart';
class EditorSession extends Equatable {
final Uri editUrl;
final String token;
final bool readOnly;
final DateTime expiresAt;
const EditorSession({
required this.editUrl,
required this.token,
required this.readOnly,
required this.expiresAt,
});
@override
List<Object?> get props => [editUrl, readOnly, expiresAt];
List<Object?> get props => [editUrl, token, readOnly, expiresAt];
factory EditorSession.fromJson(Map<String, dynamic> json) {
return EditorSession(
editUrl: Uri.parse(json['editUrl']),
token: json['token'] ?? '',
readOnly: json['readOnly'],
expiresAt: DateTime.parse(json['expiresAt']),
);

View File

@@ -104,10 +104,10 @@ func NewRouter(cfg *config.Config, db *database.DB, jwtManager *jwt.Manager, aut
// Org routes
r.Get("/orgs", func(w http.ResponseWriter, req *http.Request) {
listOrgsHandler(w, req, db, jwtManager)
listOrgsHandler(w, req, db)
})
r.Post("/orgs", func(w http.ResponseWriter, req *http.Request) {
createOrgHandler(w, req, db, auditLogger, jwtManager)
createOrgHandler(w, req, db, auditLogger)
})
// Org-scoped routes
@@ -243,7 +243,7 @@ func logoutHandler(w http.ResponseWriter, r *http.Request, jwtManager *jwt.Manag
w.Write([]byte(`{"status": "ok"}`))
}
func listOrgsHandler(w http.ResponseWriter, r *http.Request, db *database.DB, jwtManager *jwt.Manager) {
func listOrgsHandler(w http.ResponseWriter, r *http.Request, db *database.DB) {
// User ID is already set by Auth middleware
userIDStr, ok := middleware.GetUserID(r.Context())
if !ok {
@@ -263,7 +263,7 @@ func listOrgsHandler(w http.ResponseWriter, r *http.Request, db *database.DB, jw
json.NewEncoder(w).Encode(orgs)
}
func createOrgHandler(w http.ResponseWriter, r *http.Request, db *database.DB, auditLogger *audit.Logger, jwtManager *jwt.Manager) {
func createOrgHandler(w http.ResponseWriter, r *http.Request, db *database.DB, auditLogger *audit.Logger) {
// User ID is already set by Auth middleware
userIDStr, ok := middleware.GetUserID(r.Context())
if !ok {