Browse Source

implement back-end for update-search-url (defroute in web.lisp).

This feature is for updating the search-url used by this site to call out to the
Meilisearch service (which provides the search database for this website). It
doesn't touch or alter anything on the Meilisearch service/instance/server.
stable
Craig Oates 2 years ago
parent
commit
fdc0b964e0
  1. 21
      src/web.lisp

21
src/web.lisp

@ -418,6 +418,27 @@
"error")
(redirect "/login"))))))
(defroute ("/site-settings/update-search-url" :method :POST) ()
(destructuring-bind
(&key search-url authenticity-token &allow-other-keys)
(utils:request-params (lack.request:request-body-parameters ningle:*request*))
(if (not (string= authenticity-token (auth:csrf-token)))
`(,+forbidden+ (:content-type "text/plain") ("Denied"))
(hermetic:auth
(:administrator)
;; Authorised
(cond ((validation:string-is-nil-or-empty? search-url)
(utils:set-alert "No Search URL provided." "missing-data")
(redirect "/site-settings"))
(t (nera:update-search-url search-url)
(utils:set-alert "Search URL updated." "success")
(redirect "/site-settings")))
;; Not Authorised
(progn
(utils:set-alert "You are not authorised to view this page."
"error")
(redirect "/login"))))))
(defroute ("/users" :method :GET) ()
(hermetic:auth (:administrator)
;; Authorised

Loading…
Cancel
Save