close more stuff
License: MIT Signed-off-by: Henrique Dias <hacdias@gmail.com>
This commit is contained in:
parent
60c6696e10
commit
0f7f4933bb
2
frontend
2
frontend
@ -1 +1 @@
|
|||||||
Subproject commit 1bd7903569832952237a967e2f57a571294569fe
|
Subproject commit 44658d2a43fefebde554b4adeddfc6ae7e996373
|
||||||
@ -5,6 +5,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/filebrowser/filebrowser/types"
|
"github.com/filebrowser/filebrowser/types"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
@ -21,12 +22,13 @@ type modifyRequest struct {
|
|||||||
Which []string `json:"which"` // Answer to: which fields?
|
Which []string `json:"which"` // Answer to: which fields?
|
||||||
}
|
}
|
||||||
|
|
||||||
// Env ...
|
// Env contains the required info for FB to run.
|
||||||
type Env struct {
|
type Env struct {
|
||||||
Auther types.Auther
|
Auther types.Auther
|
||||||
Runner *types.Runner
|
Runner *types.Runner
|
||||||
Settings *types.Settings
|
Settings *types.Settings
|
||||||
Store *types.Store
|
Store *types.Store
|
||||||
|
mux sync.Mutex // settings mutex for Auther, Runner and Settings changes.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handler ...
|
// Handler ...
|
||||||
|
|||||||
@ -44,6 +44,9 @@ func (e *Env) settingsPutHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
e.mux.Lock()
|
||||||
|
defer e.mux.Unlock()
|
||||||
|
|
||||||
runner := &types.Runner{Commands: req.Commands}
|
runner := &types.Runner{Commands: req.Commands}
|
||||||
err = e.Store.Config.SaveRunner(runner)
|
err = e.Store.Config.SaveRunner(runner)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -68,7 +71,6 @@ func (e *Env) settingsPutHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: env locks
|
|
||||||
e.Runner = runner
|
e.Runner = runner
|
||||||
e.Settings = settings
|
e.Settings = settings
|
||||||
}
|
}
|
||||||
|
|||||||
@ -133,7 +133,41 @@ func (e *Env) userDeleteHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e *Env) userPostHandler(w http.ResponseWriter, r *http.Request) {
|
func (e *Env) userPostHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
// TODO: fill me
|
_, ok := e.getAdminUser(w,r)
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
req, ok := getUser(w, r)
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(req.Which) != 0 {
|
||||||
|
httpErr(w, r, http.StatusBadRequest, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.Data.Password == "" {
|
||||||
|
httpErr(w, r, http.StatusBadRequest, types.ErrEmptyPassword)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var err error
|
||||||
|
req.Data.Password, err = types.HashPwd(req.Data.Password)
|
||||||
|
if err != nil {
|
||||||
|
httpErr(w, r, http.StatusInternalServerError, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = e.Store.Users.Save(req.Data)
|
||||||
|
if err != nil {
|
||||||
|
httpErr(w, r, http.StatusInternalServerError, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
w.Header().Set("Location", "/settings/users/"+strconv.FormatUint(uint64(req.Data.ID), 10))
|
||||||
|
w.WriteHeader(http.StatusCreated)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Env) userPutHandler(w http.ResponseWriter, r *http.Request) {
|
func (e *Env) userPutHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|||||||
@ -218,7 +218,6 @@ var (
|
|||||||
|
|
||||||
// DetectSubtitles fills the subtitles field if the file
|
// DetectSubtitles fills the subtitles field if the file
|
||||||
// is a movie.
|
// is a movie.
|
||||||
// TODO: detect multiple languages, like FILENAME.LANG.VTT
|
|
||||||
func (f *File) DetectSubtitles() {
|
func (f *File) DetectSubtitles() {
|
||||||
f.Subtitles = []string{}
|
f.Subtitles = []string{}
|
||||||
ext := filepath.Ext(f.Path)
|
ext := filepath.Ext(f.Path)
|
||||||
|
|||||||
@ -7,8 +7,6 @@ type Store struct {
|
|||||||
Share ShareStore
|
Share ShareStore
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: wrappers to verify
|
|
||||||
|
|
||||||
// ConfigStore is used to manage configurations relativey to a data storage.
|
// ConfigStore is used to manage configurations relativey to a data storage.
|
||||||
type ConfigStore interface {
|
type ConfigStore interface {
|
||||||
Get(name string, to interface{}) error
|
Get(name string, to interface{}) error
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user