This commit is contained in:
2026-08-16 12:00:28 +02:00
parent 52f27e30fc
commit 52fb129957
7 changed files with 105 additions and 23 deletions
@@ -69,11 +69,25 @@ func (s *Server) handleAdminCloneCompanyCatalog(w http.ResponseWriter, r *http.R
ClientOrLog(w, http.StatusBadRequest, "could not clone catalog", err, catalog.ClientError)
return
}
// Point the admin session at the destination so Products / process use the cloned catalog.
if s.Sessions != nil {
s.Sessions.Put(r.Context(), auth.SessionCompanyIDKey, destID.String())
if s.Auth != nil {
if uid, ok := UserIDFromContext(r.Context()); ok && uid != uuid.Nil {
if _, memErr := s.Auth.EnsureMembership(r.Context(), uid, destID); memErr == nil {
s.Sessions.Remove(r.Context(), auth.SessionStaffHomeCompanyKey)
}
}
}
}
JSON(w, http.StatusOK, map[string]any{
"status": "ok",
"source_company_id": res.SourceCompanyID,
"dest_company_id": res.DestCompanyID,
"counts": res.Counts,
"active_company_id": destID,
})
}