fix: lint errors

This commit is contained in:
Felipe M 2025-04-22 11:56:33 +02:00
parent abcd3c3c44
commit 763a451251
Signed by: fmartingr
GPG key ID: CCFBC5637D4000A8
10 changed files with 91 additions and 55 deletions

View file

@ -194,7 +194,7 @@ func (a *Admin) addFlash(w http.ResponseWriter, r *http.Request, message string,
}
// Map internal categories to Bootstrap alert classes
alertClass := category
var alertClass string
switch category {
case "success":
alertClass = "success"
@ -249,16 +249,6 @@ func (a *Admin) getFlashes(w http.ResponseWriter, r *http.Request) []FlashMessag
return messages
}
// requireLogin middleware checks if the user is logged in
func (a *Admin) requireLogin(next http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if !a.isLoggedIn(r) {
http.Redirect(w, r, "/admin/login", http.StatusSeeOther)
return
}
next(w, r)
}
}
// render renders a template with the given data
func (a *Admin) render(w http.ResponseWriter, r *http.Request, templateName string, data TemplateData) {
@ -334,7 +324,10 @@ func (a *Admin) handleLogin(w http.ResponseWriter, r *http.Request) {
// Set session expiration
session.Options.MaxAge = 3600 * 24 * 7 // 1 week
session.Save(r, w)
err = session.Save(r, w)
if err != nil {
fmt.Printf("Error saving session: %v\n", err)
}
a.addFlash(w, r, "You were logged in", "success")
@ -715,4 +708,4 @@ func (a *Admin) handleChannelPluginDetailOrDelete(w http.ResponseWriter, r *http
// Redirect to channel plugins list
http.Redirect(w, r, "/admin/channelplugins", http.StatusSeeOther)
}
}