mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2024-10-29 19:26:16 +00:00
Offer to pass -create-admin option if no admins were found
Implements: #218
This commit is contained in:
parent
2702b4da63
commit
d1bf1f76eb
4
main.go
4
main.go
@ -61,5 +61,9 @@ func main() {
|
||||
// Static files:
|
||||
static.InitFS(files.StaticFiles())
|
||||
|
||||
if !user.HasAnyAdmins() {
|
||||
log.Println("Your wiki has no admin yet. Run Mycorrhiza with -create-admin <username> option to create an admin.")
|
||||
}
|
||||
|
||||
serveHTTP(web.Handler())
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ var tokens sync.Map
|
||||
func YieldUsers() chan *User {
|
||||
ch := make(chan *User)
|
||||
go func(ch chan *User) {
|
||||
users.Range(func(_, v interface{}) bool {
|
||||
users.Range(func(_, v any) bool {
|
||||
ch <- v.(*User)
|
||||
return true
|
||||
})
|
||||
@ -38,6 +38,15 @@ func Count() (i uint64) {
|
||||
return i
|
||||
}
|
||||
|
||||
func HasAnyAdmins() bool {
|
||||
for u := range YieldUsers() {
|
||||
if u.Group == "admin" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// HasUsername checks whether the desired user exists
|
||||
func HasUsername(username string) bool {
|
||||
_, has := users.Load(username)
|
||||
|
Loading…
Reference in New Issue
Block a user