Web UI: podcasts, radio, shares, bookmarks pages; admin podcast/jukebox management; per-user Subsonic permission editor
This commit is contained in:
@@ -48,6 +48,47 @@ func (h *Web) handleAdminUserCreate(w http.ResponseWriter, r *http.Request) {
|
||||
http.Redirect(w, r, "/admin/users", http.StatusFound)
|
||||
}
|
||||
|
||||
func (h *Web) handleAdminUserPermissions(w http.ResponseWriter, r *http.Request) {
|
||||
id := r.PathValue("id")
|
||||
target, err := database.GetUserByID(h.DB, id)
|
||||
if err != nil {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
h.page(w, r, "admin_user_permissions", "admin_users", "Permissions: "+target.Username, target)
|
||||
}
|
||||
|
||||
func (h *Web) handleAdminUserPermissionsUpdate(w http.ResponseWriter, r *http.Request) {
|
||||
id := r.PathValue("id")
|
||||
if _, err := database.GetUserByID(h.DB, id); err != nil {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
if err := r.ParseForm(); err != nil {
|
||||
http.Error(w, "bad request", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
get := func(name string) bool { return r.FormValue(name) == "1" }
|
||||
perms := database.Permissions{
|
||||
Settings: get("settings"),
|
||||
Stream: get("stream"),
|
||||
Download: get("download"),
|
||||
Upload: get("upload"),
|
||||
Playlist: get("playlist"),
|
||||
CoverArt: get("cover_art"),
|
||||
Comment: get("comment"),
|
||||
Podcast: get("podcast"),
|
||||
Share: get("share"),
|
||||
Jukebox: get("jukebox"),
|
||||
VideoConversion: get("video_conversion"),
|
||||
}
|
||||
if err := database.SetUserPermissions(h.DB, id, perms); err != nil {
|
||||
http.Error(w, "internal error", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
http.Redirect(w, r, "/admin/users", http.StatusFound)
|
||||
}
|
||||
|
||||
func (h *Web) handleAdminUserToggleDisabled(w http.ResponseWriter, r *http.Request) {
|
||||
id := r.PathValue("id")
|
||||
target, err := database.GetUserByID(h.DB, id)
|
||||
|
||||
Reference in New Issue
Block a user