Revert "Adminbereich mit Rollen und Nutzerauswertung ergänzen"
This reverts commit e432943ea7.
This commit is contained in:
@@ -125,23 +125,6 @@ func (s *Server) requireAuth(next http.Handler) http.Handler {
|
||||
})
|
||||
}
|
||||
|
||||
// Admin rights are read from PostgreSQL for every request. A previously
|
||||
// issued token does not preserve privileges after an account is demoted.
|
||||
func (s *Server) requireAdmin(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
user, err := s.store.GetUser(r.Context(), currentUserID(r))
|
||||
if err != nil {
|
||||
writeError(w, http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
if user.Role != "admin" {
|
||||
writeError(w, http.StatusForbidden, nil)
|
||||
return
|
||||
}
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
|
||||
func currentUserID(r *http.Request) string {
|
||||
value, _ := r.Context().Value(userIDKey).(string)
|
||||
return value
|
||||
|
||||
Reference in New Issue
Block a user