mirror of
https://github.com/nkanaev/yarr.git
synced 2025-12-15 08:37:21 +00:00
login page
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user