mirror of
https://github.com/mickael-kerjean/filestash.git
synced 2025-11-01 19:32:27 +08:00
chore (GenerateID): change signature for GenerateID
This commit is contained in:
@ -191,11 +191,10 @@ func verify(something []byte) ([]byte, error) {
|
||||
}
|
||||
|
||||
// Create a unique ID that can be use to identify different session
|
||||
func GenerateID(ctx *App) string {
|
||||
func GenerateID(params map[string]string) string {
|
||||
p := ""
|
||||
|
||||
orderedKeys := make([]string, len(ctx.Session))
|
||||
for key, _ := range ctx.Session {
|
||||
orderedKeys := make([]string, len(params))
|
||||
for key, _ := range params {
|
||||
orderedKeys = append(orderedKeys, key)
|
||||
}
|
||||
sort.Strings(orderedKeys)
|
||||
@ -206,8 +205,8 @@ func GenerateID(ctx *App) string {
|
||||
case "password":
|
||||
case "path":
|
||||
default:
|
||||
if val := ctx.Session[key]; val != "" {
|
||||
p += key + "=>" + ctx.Session[key] + ", "
|
||||
if val := params[key]; val != "" {
|
||||
p += key + "=>" + params[key] + ", "
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ func SessionGet(ctx *App, res http.ResponseWriter, req *http.Request) {
|
||||
}
|
||||
r.IsAuth = true
|
||||
r.Home = NewString(home)
|
||||
r.Backend = GenerateID(ctx)
|
||||
r.Backend = GenerateID(ctx.Session)
|
||||
if ctx.Share.Id == "" && Config.Get("features.protection.enable_chromecast").Bool() {
|
||||
r.Authorization = ctx.Authorization
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@ func ShareList(ctx *App, res http.ResponseWriter, req *http.Request) {
|
||||
return
|
||||
}
|
||||
listOfSharedLinks, err := model.ShareList(
|
||||
GenerateID(ctx),
|
||||
GenerateID(ctx.Session),
|
||||
path,
|
||||
)
|
||||
if err != nil {
|
||||
@ -59,7 +59,7 @@ func ShareUpsert(ctx *App, res http.ResponseWriter, req *http.Request) {
|
||||
}(),
|
||||
Backend: func() string {
|
||||
if ctx.Share.Id == "" {
|
||||
return GenerateID(ctx)
|
||||
return GenerateID(ctx.Session)
|
||||
}
|
||||
return ctx.Share.Backend
|
||||
}(),
|
||||
|
||||
@ -137,7 +137,7 @@ func CanManageShare(fn HandlerFunc) HandlerFunc {
|
||||
SendErrorResult(res, err)
|
||||
return
|
||||
}
|
||||
if s.Backend == GenerateID(ctx) {
|
||||
if s.Backend == GenerateID(ctx.Session) {
|
||||
fn(ctx, res, req)
|
||||
return
|
||||
}
|
||||
@ -155,7 +155,7 @@ func CanManageShare(fn HandlerFunc) HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
id := GenerateID(ctx)
|
||||
id := GenerateID(ctx.Session)
|
||||
if s.Backend == id {
|
||||
if s.CanShare == true {
|
||||
fn(ctx, res, req)
|
||||
|
||||
@ -67,7 +67,7 @@ func logger(ctx App, res http.ResponseWriter, req *http.Request) {
|
||||
if ctx.Session["type"] == "" {
|
||||
return "null"
|
||||
}
|
||||
return GenerateID(&ctx)
|
||||
return GenerateID(ctx.Session)
|
||||
}(),
|
||||
RequestID: func() string {
|
||||
defer func() string {
|
||||
|
||||
@ -88,7 +88,7 @@ func (git Git) Init(params map[string]string, app *App) (IBackend, error) {
|
||||
p.committerEmail = "https://filestash.app"
|
||||
}
|
||||
|
||||
hash := GenerateID(app)
|
||||
hash := GenerateID(params)
|
||||
p.basePath = GetAbsolutePath(
|
||||
TMP_PATH,
|
||||
"git_"+hash,
|
||||
|
||||
@ -196,7 +196,7 @@ func IframeContentHandler(ctx *App, res http.ResponseWriter, req *http.Request)
|
||||
return
|
||||
}
|
||||
|
||||
userId = GenerateID(ctx)
|
||||
userId = GenerateID(ctx.Session)
|
||||
f, err := ctx.Backend.Cat(path)
|
||||
if err != nil {
|
||||
SendErrorResult(res, err)
|
||||
|
||||
@ -131,7 +131,7 @@ func hls_playlist(reader io.ReadCloser, ctx *App, res *http.ResponseWriter, req
|
||||
return reader, nil
|
||||
}
|
||||
|
||||
cacheName := "vid_" + GenerateID(ctx) + "_" + QuickHash(path, 10) + ".dat"
|
||||
cacheName := "vid_" + GenerateID(ctx.Session) + "_" + QuickHash(path, 10) + ".dat"
|
||||
cachePath := GetAbsolutePath(
|
||||
VideoCachePath,
|
||||
cacheName,
|
||||
|
||||
Reference in New Issue
Block a user