diff --git a/backend/routes/routes.go b/backend/routes/routes.go index 86433a8..5fe3b9f 100644 --- a/backend/routes/routes.go +++ b/backend/routes/routes.go @@ -41,7 +41,17 @@ func RoutesProtected(r *mux.Router, db *gorm.DB) { r.HandleFunc("/test/send2", renders.TestMessagesPages2) r.HandleFunc("/admin/user/{id}/conversation-thread", renders.AdminConversationThread(db)).Methods("GET") r.HandleFunc("/api/message/send2", handlers.HandleTemplateTest(db)).Methods("POST") - + r.HandleFunc("/logout", func(w http.ResponseWriter, r *http.Request) { + http.SetCookie(w, &http.Cookie{ + Name: "token", + Value: "", + Path: "/", + MaxAge: -1, + HttpOnly: true, + }) + http.Redirect(w, r, "/login", http.StatusSeeOther) + }) + // // Ici on place les vues et API qui doivent être protégées diff --git a/frontend/templates/dashboard.pages.tmpl b/frontend/templates/dashboard.pages.tmpl index 0725de4..dd680c9 100644 --- a/frontend/templates/dashboard.pages.tmpl +++ b/frontend/templates/dashboard.pages.tmpl @@ -12,6 +12,8 @@