login_show.go 817 B

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