From dadde0cc89d477a253c344665a3612c2b6ad0000 Mon Sep 17 00:00:00 2001 From: 1e99 Date: Sat, 12 Apr 2025 13:31:30 +0200 Subject: [PATCH] remove delete button --- index.tmpl | 7 ------- main.go | 1 - routes/index.go | 24 ------------------------ 3 files changed, 32 deletions(-) diff --git a/index.tmpl b/index.tmpl index 05566db..be3cfad 100644 --- a/index.tmpl +++ b/index.tmpl @@ -88,7 +88,6 @@ Description Created at Ended at - Actions @@ -99,12 +98,6 @@ {{ $session.Description }} {{ $session.CreatedAt.Format "02.01.2006 15:04:05" }} {{ $session.EndedAt.Format "02.01.2006 15:04:05" }} - -
- - -
- {{ end }} diff --git a/main.go b/main.go index fd82b7b..92b874f 100644 --- a/main.go +++ b/main.go @@ -48,7 +48,6 @@ func Run() error { mux.Handle("GET /", routes.GetIndex(device, storage, tmpl)) mux.Handle("POST /start_session", routes.StartSession(logger, storage)) mux.Handle("POST /end_session", routes.EndSession(logger, storage)) - mux.Handle("POST /delete_session", routes.DeleteSession(logger, storage)) mux.Handle("POST /api/session", routes.APIStartSession(logger, storage)) mux.Handle("DELETE /api/session/{session_id}", routes.APIEndSession(logger, storage)) diff --git a/routes/index.go b/routes/index.go index 608af97..0dd2c8e 100644 --- a/routes/index.go +++ b/routes/index.go @@ -83,27 +83,3 @@ func EndSession(logger *log.Logger, storage sessions.Storage) http.HandlerFunc { logger.Printf("Ended session for %s via webpanel (id = %s)", req.RemoteAddr, sessionId) } } - -func DeleteSession(logger *log.Logger, storage sessions.Storage) http.HandlerFunc { - return func(res http.ResponseWriter, req *http.Request) { - err := req.ParseMultipartForm(10 * 1024) - if err != nil { - http.Error(res, "", http.StatusBadRequest) - return - } - - sessionId := req.FormValue("session_id") - err = storage.DeleteSession(sessionId) - switch { - case err == sessions.ErrUnknownSession: - http.Error(res, "", http.StatusNotFound) - return - case err != nil: - http.Error(res, "", http.StatusInternalServerError) - return - } - - http.Redirect(res, req, "/", http.StatusFound) - logger.Printf("Deleted session for %s via webpanel (id = %s)", req.RemoteAddr, sessionId) - } -}