Show login page
This commit is contained in:
parent
32c8f0cfa0
commit
0fa2756b1b
2
main.go
2
main.go
|
@ -619,7 +619,7 @@ func (h *indexHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
}()
|
||||
|
||||
if !sess.LoggedIn {
|
||||
http.Redirect(w, r, "/", http.StatusFound)
|
||||
http.Redirect(w, r, "/auth/login", http.StatusFound)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
19
search.go
19
search.go
|
@ -2,6 +2,8 @@ package main
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
|
@ -39,6 +41,23 @@ func NewSearchHandler(searchIndex bleve.Index) (http.Handler, error) {
|
|||
}
|
||||
|
||||
func (s *searchHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
defer r.Body.Close()
|
||||
|
||||
sess, err := NewSession(w, r)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), 500)
|
||||
return
|
||||
}
|
||||
defer func() {
|
||||
if err := sess.Flush(); err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
}()
|
||||
if !sess.LoggedIn {
|
||||
fmt.Fprint(w, "{}")
|
||||
return
|
||||
}
|
||||
|
||||
q := bleve.NewQueryStringQuery(r.URL.Query().Get("q"))
|
||||
sr := bleve.NewSearchRequest(q)
|
||||
results, err := s.searchIndex.Search(sr)
|
||||
|
|
Loading…
Reference in New Issue
Block a user