Added 503 error page and streamlined error paging
This commit is contained in:
@@ -3,7 +3,7 @@ package middleware
|
||||
import (
|
||||
"net/http"
|
||||
"projectreshoot/contexts"
|
||||
"projectreshoot/view/page"
|
||||
"projectreshoot/handlers"
|
||||
)
|
||||
|
||||
// Checks if the user is set in the context and shows 401 page if not logged in
|
||||
@@ -11,12 +11,7 @@ func RequiresLogin(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
user := contexts.GetUser(r.Context())
|
||||
if user == nil {
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
page.Error(
|
||||
"401",
|
||||
"Unauthorized",
|
||||
"Please login to view this page",
|
||||
).Render(r.Context(), w)
|
||||
handlers.ErrorPage(http.StatusUnauthorized, w, r)
|
||||
return
|
||||
}
|
||||
next.ServeHTTP(w, r)
|
||||
|
||||
Reference in New Issue
Block a user