From 44bdec65702395c5f4275e873dbbf7b6e43880c9 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Sun, 25 Sep 2022 20:07:55 +0100 Subject: [PATCH] implement the /edit/archive defroute -- updates the entries text. --- src/web.lisp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/web.lisp b/src/web.lisp index 5aa5a46..eb2101f 100644 --- a/src/web.lisp +++ b/src/web.lisp @@ -1167,8 +1167,24 @@ (redirect "/login"))))))) (defroute ("/edit/archive" :method :POST) () - (utils:set-alert "ROUTE NOT IMPLEMENTED") - (redirect "/user/archive")) + (destructuring-bind + (&key slug page-content authenticity-token &allow-other-keys) + (utils:request-params (lack.request:request-body-parameters ningle:*request*)) + (cond ((not (string= authenticity-token (auth:csrf-token))) + `(,+forbidden+ (:content-type "text/plain") ("Denied"))) + (t (hermetic:auth + (:logged-in) + ;; Authorised + (cond ((utils:string-is-nil-or-empty? slug) + (utils:set-alert "Archive entry cannot be found.") + (redirect "/user/archive")) + + (t (storage:store-text "" "archive" slug page-content) + (utils:set-alert "Archive entry updated.") + (redirect (format nil "/edit/archive/~a" slug)))) + ;; Not Authorised + (progn (utils:set-alert "You are not logged in.") + (redirect "/login"))))))) (defroute ("/archive/delete/entry" :method :POST) () (destructuring-bind