From f11314488c87786dbf753581adf038181bf77350 Mon Sep 17 00:00:00 2001 From: bouncepaw Date: Sun, 14 Mar 2021 18:29:57 +0500 Subject: [PATCH] Add /admin/reindex-users --- http_admin.go | 10 ++++++++++ views/stuff.qtpl | 6 ++++++ views/stuff.qtpl.go | 32 +++++++++++++++++++------------- 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/http_admin.go b/http_admin.go index 2b20fb5..2b95e22 100644 --- a/http_admin.go +++ b/http_admin.go @@ -5,6 +5,7 @@ import ( "net/http" "github.com/bouncepaw/mycorrhiza/user" + "github.com/bouncepaw/mycorrhiza/util" "github.com/bouncepaw/mycorrhiza/views" ) @@ -13,6 +14,7 @@ func initAdmin() { if user.AuthUsed { http.HandleFunc("/admin", handlerAdmin) http.HandleFunc("/admin/shutdown", handlerAdminShutdown) + http.HandleFunc("/admin/reindex-users", handlerAdminReindexUsers) } } @@ -31,3 +33,11 @@ func handlerAdminShutdown(w http.ResponseWriter, rq *http.Request) { log.Fatal("An admin commanded the wiki to shutdown") } } + +func handlerAdminReindexUsers(w http.ResponseWriter, rq *http.Request) { + log.Println(rq.URL) + if user.CanProceed(rq, "admin") && rq.Method == "POST" { + user.ReadUsersFromFilesystem() + http.Redirect(w, rq, "/hypha/"+util.UserHypha, http.StatusSeeOther) + } +} diff --git a/views/stuff.qtpl b/views/stuff.qtpl index 99354ca..96ee43e 100644 --- a/views/stuff.qtpl +++ b/views/stuff.qtpl @@ -141,6 +141,12 @@ for u := range user.YieldUsers() { +
+
+ Reindex users + +
+
diff --git a/views/stuff.qtpl.go b/views/stuff.qtpl.go index e5c2dda..170db4c 100644 --- a/views/stuff.qtpl.go +++ b/views/stuff.qtpl.go @@ -468,35 +468,41 @@ func StreamAdminPanelHTML(qw422016 *qt422016.Writer) { +
+
+ Reindex users + +
+
`) -//line views/stuff.qtpl:147 +//line views/stuff.qtpl:153 } -//line views/stuff.qtpl:147 +//line views/stuff.qtpl:153 func WriteAdminPanelHTML(qq422016 qtio422016.Writer) { -//line views/stuff.qtpl:147 +//line views/stuff.qtpl:153 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/stuff.qtpl:147 +//line views/stuff.qtpl:153 StreamAdminPanelHTML(qw422016) -//line views/stuff.qtpl:147 +//line views/stuff.qtpl:153 qt422016.ReleaseWriter(qw422016) -//line views/stuff.qtpl:147 +//line views/stuff.qtpl:153 } -//line views/stuff.qtpl:147 +//line views/stuff.qtpl:153 func AdminPanelHTML() string { -//line views/stuff.qtpl:147 +//line views/stuff.qtpl:153 qb422016 := qt422016.AcquireByteBuffer() -//line views/stuff.qtpl:147 +//line views/stuff.qtpl:153 WriteAdminPanelHTML(qb422016) -//line views/stuff.qtpl:147 +//line views/stuff.qtpl:153 qs422016 := string(qb422016.B) -//line views/stuff.qtpl:147 +//line views/stuff.qtpl:153 qt422016.ReleaseByteBuffer(qb422016) -//line views/stuff.qtpl:147 +//line views/stuff.qtpl:153 return qs422016 -//line views/stuff.qtpl:147 +//line views/stuff.qtpl:153 }