1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2025-01-05 17:40:26 +00:00

Add /admin/reindex-users

This commit is contained in:
bouncepaw 2021-03-14 18:29:57 +05:00
parent 8fc036ba1c
commit f11314488c
3 changed files with 35 additions and 13 deletions

View File

@ -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)
}
}

View File

@ -141,6 +141,12 @@ for u := range user.YieldUsers() {
<input type="submit">
</fieldset>
</form>
<form action="/admin/reindex-users" method="POST" style="float:left">
<fieldset>
<legend>Reindex users</legend>
<input type="submit">
</fieldset>
</form>
</section>
</main>
</div>

View File

@ -468,35 +468,41 @@ func StreamAdminPanelHTML(qw422016 *qt422016.Writer) {
<input type="submit">
</fieldset>
</form>
<form action="/admin/reindex-users" method="POST" style="float:left">
<fieldset>
<legend>Reindex users</legend>
<input type="submit">
</fieldset>
</form>
</section>
</main>
</div>
`)
//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
}