1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-12-12 05:20:26 +00:00

Add /admin/shutdown

This commit is contained in:
bouncepaw 2021-02-18 19:50:37 +05:00
parent 77688b3869
commit 58ed6ecdfb
2 changed files with 12 additions and 0 deletions

11
main.go
View File

@ -75,6 +75,14 @@ func handlerReindex(w http.ResponseWriter, rq *http.Request) {
http.Redirect(w, rq, "/", http.StatusSeeOther)
}
// Stop the wiki
func handlerAdminShutdown(w http.ResponseWriter, rq *http.Request) {
log.Println(rq.URL)
if user.CanProceed(rq, "admin/shutdown") {
log.Fatal("An admin commanded the wiki to shutdown")
}
}
// Update header links by reading the configured hypha, if there is any, or resorting to default values.
func handlerUpdateHeaderLinks(w http.ResponseWriter, rq *http.Request) {
log.Println(rq.URL)
@ -195,6 +203,9 @@ func main() {
})
http.HandleFunc("/static/common.css", handlerStyle)
http.HandleFunc("/static/icon/", handlerIcon)
if user.AuthUsed {
http.HandleFunc("/admin/shutdown", handlerAdminShutdown)
}
http.HandleFunc("/", func(w http.ResponseWriter, rq *http.Request) {
http.Redirect(w, rq, "/hypha/"+util.HomePage, http.StatusSeeOther)
})

View File

@ -26,6 +26,7 @@ var minimalRights = map[string]int{
"delete-ask": 3,
"delete-confirm": 3,
"reindex": 4,
"admin/shutdown": 4,
}
// Group — Right