4
0

login_show.go 800 B

1234567891011121314151617181920212223242526272829303132
  1. // Copyright 2017 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/http/route"
  10. "miniflux.app/ui/session"
  11. "miniflux.app/ui/view"
  12. )
  13. func (h *handler) showLoginPage(w http.ResponseWriter, r *http.Request) {
  14. if request.IsAuthenticated(r) {
  15. user, err := h.store.UserByID(request.UserID(r))
  16. if err != nil {
  17. html.ServerError(w, r, err)
  18. return
  19. }
  20. html.Redirect(w, r, route.Path(h.router, user.DefaultHomePage))
  21. return
  22. }
  23. sess := session.New(h.store, request.SessionID(r))
  24. view := view.New(h.tpl, r, sess)
  25. html.OK(w, r, view.Render("login"))
  26. }