 
           (auth/logged-in? req)
           {:status 403
-           ;; TODO: use an image here
-           :body "Please request permission to access this document"}
+           :headers {"Content-Type" "image/svg+xml"
+                     "Cache-Control" "no-cache; private"}
+           :body (render/render-layers private-layers :invert-colors? (-> req :params :printer-friendly (= "false")))}
 
           :else
           {:status 401
-           ;; TODO: use an image here
-           :body "Please log in so that we can check if you have permission to access this document"})))
+           :headers {"Content-Type" "image/svg+xml"
+                     "Cache-Control" "no-cache; private"}
+           :body (render/render-layers private-layers :invert-colors? (-> req :params :printer-friendly (= "false")))})))
 
 (defpage doc-png "/document/:document-id.png" [req]
   (let [document-id (-> req :params :document-id)

                                                                        (urls/from-doc doc)]])
                 "Document not found")}))))

(defn image-cache-headers [db doc]
  (let [last-modified-instant (or (doc-http/last-modified-instant db doc)
                                  (java.util.Date.))]


          (auth/logged-in? req)
          {:status 403
           :headers {"Content-Type" "image/png"
                     "Cache-Control" "no-cache; private"}
           :body (convert/svg->png (render/render-layers private-layers
                                                         :invert-colors? (-> req :params :printer-friendly (= "false"))
                                                         :size-limit 800))}

          :else
          {:status 401
           :headers {"Content-Type" "image/png"
                     "Cache-Control" "no-cache; private"}
           :body (convert/svg->png (render/render-layers private-layers
                                                         :invert-colors? (-> req :params :printer-friendly (= "false"))
                                                         :size-limit 800))})))

(defpage doc-pdf "/document/:document-id.pdf" [req]
  (let [document-id (-> req :params :document-id)
