all repos — flounder @ 3d63a8ce4b80ae8cd81bff62ef03e4d4ea8b436f

A small site builder for the Gemini protocol

Allow admin to view hidden files on TL
alex wennerberg alex@alexwennerberg.com
Sat, 05 Dec 2020 17:46:08 -0800
commit

3d63a8ce4b80ae8cd81bff62ef03e4d4ea8b436f

parent

ade0a38005835f48624cd3c356465f7456c79a2f

4 files changed, 5 insertions(+), 4 deletions(-)

jump to
M admin.goadmin.go

@@ -47,6 +47,7 @@ _, err := DB.Exec("UPDATE user SET admin = true WHERE username = $1", username)

if err != nil { return err } + log.Println("Made admin user", username) return nil }
M gemini.gogemini.go

@@ -18,7 +18,7 @@ t, err := template.ParseFiles("templates/index.gmi")

if err != nil { log.Fatal(err) } - files, err := getIndexFiles() + files, err := getIndexFiles(false) users, err := getActiveUserNames() if err != nil { log.Println(err)
M http.gohttp.go

@@ -57,7 +57,7 @@ return

} authd, _, isAdmin := getAuthUser(r) - indexFiles, err := getIndexFiles() + indexFiles, err := getIndexFiles(isAdmin) if err != nil { log.Println(err) renderDefaultError(w, http.StatusInternalServerError)
M main.gomain.go

@@ -97,14 +97,14 @@ r := strings.Split(filePath, "/")[l]

return r } -func getIndexFiles() ([]*File, error) { // cache this function +func getIndexFiles(admin bool) ([]*File, error) { // cache this function result := []*File{} err := filepath.Walk(c.FilesDirectory, func(thepath string, info os.FileInfo, err error) error { if err != nil { log.Printf("Failure accessing a path %q: %v\n", thepath, err) return err // think about } - if info.IsDir() && info.Name() == HIDDEN_FOLDER { + if !admin && info.IsDir() && info.Name() == HIDDEN_FOLDER { return filepath.SkipDir } // make this do what it should