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