diff --git a/backend/handlers/handle_auth.go b/backend/handlers/handle_auth.go index 9655e64..38bb985 100644 --- a/backend/handlers/handle_auth.go +++ b/backend/handlers/handle_auth.go @@ -155,3 +155,24 @@ func (store *Store) Login(ctx *gin.Context) { ctx.JSON(http.StatusAccepted, user) } + +func (store *Store) Logout(ctx *gin.Context) { + ctx.SetCookie( + "access_token", + "", + -1, + store.Auth.Config.Endpoint, + store.Auth.Config.Domain, + true, true, + ) + ctx.SetCookie( + "refresh_token", + "", + -1, + store.Auth.Config.Endpoint, + store.Auth.Config.Domain, + true, true, + ) + + ctx.Status(http.StatusOK) +} diff --git a/backend/main.go b/backend/main.go index 780163a..896947c 100644 --- a/backend/main.go +++ b/backend/main.go @@ -59,6 +59,7 @@ func main() { r.POST("/auth/login", store.Login) r.POST("/auth/refresh", store.RefreshToken) r.GET("/auth/check", store.CheckToken) + r.POST("/auth/logout", store.Logout) r.GET("/spotify/callback", store.CompleteSpotifyAuth) r.GET("/spotify/listening", store.ListeningTo)