login_show.go 750 B

12345678910111213141516171819202122232425262728
  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/response"
  8. "miniflux.app/http/request"
  9. "miniflux.app/http/response/html"
  10. "miniflux.app/http/route"
  11. "miniflux.app/ui/session"
  12. "miniflux.app/ui/view"
  13. )
  14. // ShowLoginPage shows the login form.
  15. func (c *Controller) ShowLoginPage(w http.ResponseWriter, r *http.Request) {
  16. if request.IsAuthenticated(r) {
  17. response.Redirect(w, r, route.Path(c.router, "unread"))
  18. return
  19. }
  20. sess := session.New(c.store, request.SessionID(r))
  21. view := view.New(c.tpl, r, sess)
  22. html.OK(w, r, view.Render("login"))
  23. }