login page
This commit is contained in:
parent
94d1659ad5
commit
0e2da62081
5 changed files with 104 additions and 3 deletions
|
|
@ -49,6 +49,14 @@ func (h Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
|||
rw.WriteHeader(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
if h.requiresAuth() && !route.skipAuth {
|
||||
if !userIsAuthenticated(req, h.Username, h.Password) {
|
||||
rw.WriteHeader(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
ctx := context.WithValue(req.Context(), ctxHandler, &h)
|
||||
ctx = context.WithValue(ctx, ctxVars, vars)
|
||||
route.handler(rw, req.WithContext(ctx))
|
||||
|
|
@ -137,6 +145,10 @@ func (h *Handler) startJobs() {
|
|||
}
|
||||
}
|
||||
|
||||
func (h Handler) requiresAuth() bool {
|
||||
return h.Username != "" && h.Password != ""
|
||||
}
|
||||
|
||||
func (h *Handler) fetchAllFeeds() {
|
||||
h.log.Print("Refreshing all feeds")
|
||||
for _, feed := range h.db.ListFeeds() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue