diff --git a/src/web.lisp b/src/web.lisp index 2e36db3..3ad1f47 100644 --- a/src/web.lisp +++ b/src/web.lisp @@ -1485,6 +1485,26 @@ (format nil "~a" (mito.dao.mixin:object-updated-at item)))))))))) +(defroute ("/danger/repopulate-search-db" :method :POST) () + (destructuring-bind + (&key 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 + (:administrator) + ;; Authorised + (progn + (search:repopulate-database (nera:get-all-archive-entries)) + (utils:set-alert + "Search database re-populated. Great Success!" "success") + (redirect "/site-settings")) + ;; Not Authorised + (progn (utils:set-alert + "You are not authorised to use this feature." + "error") + (redirect "/login"))))))) + ;; ;; Error pages