user_create.go 973 B

123456789101112131415161718192021222324252627282930313233343536373839
  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 // 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) showCreateUserPage(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. if !user.IsAdmin {
  22. html.Forbidden(w, r)
  23. return
  24. }
  25. view.Set("form", &form.UserForm{})
  26. view.Set("menu", "settings")
  27. view.Set("user", user)
  28. view.Set("countUnread", h.store.CountUnreadEntries(user.ID))
  29. view.Set("countErrorFeeds", h.store.CountUserFeedsWithErrors(user.ID))
  30. html.OK(w, r, view.Render("create_user"))
  31. }