Ver Fonte

add /auth/logout endpoint

neyrogovnarik há 2 meses atrás
pai
commit
88d6faccf2
2 ficheiros alterados com 5 adições e 0 exclusões
  1. 1 0
      backend/cmd/api/main.go
  2. 4 0
      backend/internal/handlers/auth.go

+ 1 - 0
backend/cmd/api/main.go

@@ -99,6 +99,7 @@ func main() {
 		r.Group(func(r chi.Router) {
 			r.Use(middleware.AuthMiddleware(authSvc))
 			r.Get("/auth/me", authHandler.Me)
+			r.Post("/auth/logout", authHandler.Logout)
 
 			// Users
 			r.Patch("/users/me", userHandler.UpdateMe)

+ 4 - 0
backend/internal/handlers/auth.go

@@ -107,6 +107,10 @@ func (h *AuthHandler) Refresh(w http.ResponseWriter, r *http.Request) {
 	writeJSON(w, http.StatusOK, result)
 }
 
+func (h *AuthHandler) Logout(w http.ResponseWriter, r *http.Request) {
+	w.WriteHeader(http.StatusNoContent)
+}
+
 func (h *AuthHandler) Me(w http.ResponseWriter, r *http.Request) {
 	userID := middleware.GetUserID(r.Context())
 	if userID == "" {