session_remove.go 919 B

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright 2018 Frédéric Guillot. All rights reserved.
  2. // Use of this source code is governed by the Apache 2.0
  3. // license that can be found in the LICENSE file.
  4. package ui
  5. import (
  6. "net/http"
  7. "github.com/miniflux/miniflux/http/context"
  8. "github.com/miniflux/miniflux/http/request"
  9. "github.com/miniflux/miniflux/http/response"
  10. "github.com/miniflux/miniflux/http/response/html"
  11. "github.com/miniflux/miniflux/http/route"
  12. "github.com/miniflux/miniflux/logger"
  13. )
  14. // RemoveSession remove a user session.
  15. func (c *Controller) RemoveSession(w http.ResponseWriter, r *http.Request) {
  16. ctx := context.New(r)
  17. sessionID, err := request.IntParam(r, "sessionID")
  18. if err != nil {
  19. html.BadRequest(w, err)
  20. return
  21. }
  22. err = c.store.RemoveUserSessionByID(ctx.UserID(), sessionID)
  23. if err != nil {
  24. logger.Error("[Controller:RemoveSession] %v", err)
  25. }
  26. response.Redirect(w, r, route.Path(c.router, "sessions"))
  27. }