Frontend: Firewall-Tabelle mit CPU/RAM/Disk/Uptime/Gateways, sortierbar, Slide-in Detail-Panel mit Tabs (Uebersicht, Interfaces, Dienste, VPN, Routen, DHCP, Zertifikate, Backups)
This commit is contained in:
@@ -50,6 +50,7 @@ func (h *Handler) SetupRoutes(mux *http.ServeMux, hub *ws.Hub) {
|
||||
// User-Routes
|
||||
mux.HandleFunc("GET /api/v1/users", h.listUsers)
|
||||
mux.HandleFunc("POST /api/v1/users", h.createUser)
|
||||
mux.HandleFunc("PUT /api/v1/users/{id}/password", h.changePassword)
|
||||
mux.HandleFunc("DELETE /api/v1/users/{id}", h.deleteUser)
|
||||
|
||||
// WebSocket und Tunnel-Routes
|
||||
|
||||
@@ -39,6 +39,31 @@ func (h *Handler) createUser(w http.ResponseWriter, r *http.Request) {
|
||||
writeJSON(w, http.StatusCreated, u)
|
||||
}
|
||||
|
||||
// PUT /api/v1/users/{id}/password
|
||||
func (h *Handler) changePassword(w http.ResponseWriter, r *http.Request) {
|
||||
id, err := strconv.Atoi(r.PathValue("id"))
|
||||
if err != nil {
|
||||
writeError(w, http.StatusBadRequest, "Ungueltige ID")
|
||||
return
|
||||
}
|
||||
var req struct {
|
||||
Password string `json:"password"`
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil || req.Password == "" {
|
||||
writeError(w, http.StatusBadRequest, "password ist erforderlich")
|
||||
return
|
||||
}
|
||||
if len(req.Password) < 6 {
|
||||
writeError(w, http.StatusBadRequest, "Passwort muss mindestens 6 Zeichen lang sein")
|
||||
return
|
||||
}
|
||||
if err := h.db.ChangePassword(id, req.Password); err != nil {
|
||||
writeError(w, http.StatusInternalServerError, "Passwort aendern fehlgeschlagen")
|
||||
return
|
||||
}
|
||||
writeJSON(w, http.StatusOK, map[string]string{"message": "Passwort geaendert"})
|
||||
}
|
||||
|
||||
// DELETE /api/v1/users/{id}
|
||||
func (h *Handler) deleteUser(w http.ResponseWriter, r *http.Request) {
|
||||
id, err := strconv.Atoi(r.PathValue("id"))
|
||||
|
||||
Reference in New Issue
Block a user