Browse Source

implement /edit/archive/:slug defroute (HTTP GET request).

stable
Craig Oates 2 years ago
parent
commit
93a59aaad4
  1. 20
      src/web.lisp

20
src/web.lisp

@ -1028,11 +1028,27 @@
(progn (utils:set-alert "You are not logged in.") (progn (utils:set-alert "You are not logged in.")
(redirect "/login"))))))) (redirect "/login")))))))
(defroute ("/edit/archive/:slug" :method :GET) (&key slug)
(hermetic:auth (:logged-in)
;; Authorised
(let ((alert (utils:get-and-reset-alert)))
(render "/user/edit-archive.html"
(append (auth:auth-user-data)
`(:alert ,alert
:system-data ,(nera:system-data)
:db-data ,(nera:get-archive-entry :slug slug)
:data ,(storage:open-text-file
"" "archive" slug)))))
;; Not Authorised
(progn
(utils:set-alert "You are not logged in.")
(redirect "/login"))))
(defroute ("/archive/delete/entry" :method :POST) () (defroute ("/archive/delete/entry" :method :POST) ()
(destructuring-bind (destructuring-bind
(&key slug authenticity-token &allow-other-keys) (&key slug authenticity-token &allow-other-keys)
(utils:request-params (lack.request:request-body-parameters ningle:*request*)) (utils:request-params (lack.request:request-body-parameters ningle:*request*))
(step
(cond ((not (string= authenticity-token (auth:csrf-token))) (cond ((not (string= authenticity-token (auth:csrf-token)))
`(,+forbidden+ (:content-type "text/plain") ("Denied"))) `(,+forbidden+ (:content-type "text/plain") ("Denied")))
(t (hermetic:auth (t (hermetic:auth
@ -1073,7 +1089,7 @@
(redirect "/user/archive"))) (redirect "/user/archive")))
;; Not Authorised ;; Not Authorised
(progn (utils:set-alert "You are not authorised to delete this archive entry.") (progn (utils:set-alert "You are not authorised to delete this archive entry.")
(redirect "/login")))))))) (redirect "/login")))))))
;; ;;
;; Error pages ;; Error pages

Loading…
Cancel
Save