api_key_create.go 924 B

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright 2020 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 // import "miniflux.app/ui"
  5. import (
  6. "net/http"
  7. "miniflux.app/http/request"
  8. "miniflux.app/http/response/html"
  9. "miniflux.app/ui/form"
  10. "miniflux.app/ui/session"
  11. "miniflux.app/ui/view"
  12. )
  13. func (h *handler) showCreateAPIKeyPage(w http.ResponseWriter, r *http.Request) {
  14. sess := session.New(h.store, request.SessionID(r))
  15. view := view.New(h.tpl, r, sess)
  16. user, err := h.store.UserByID(request.UserID(r))
  17. if err != nil {
  18. html.ServerError(w, r, err)
  19. return
  20. }
  21. view.Set("form", &form.APIKeyForm{})
  22. view.Set("menu", "settings")
  23. view.Set("user", user)
  24. view.Set("countUnread", h.store.CountUnreadEntries(user.ID))
  25. view.Set("countErrorFeeds", h.store.CountUserFeedsWithErrors(user.ID))
  26. html.OK(w, r, view.Render("create_api_key"))
  27. }