mirror of
https://github.com/mickael-kerjean/filestash.git
synced 2025-10-29 00:55:51 +08:00
fix (share): access shared link multiple times issue
When trying to access a shared link protected with a password many times over, user would see an ErrNotValid (case 2 from ShareVerifyProof in ctrl/share.go). With this commit, we are making sure the proof cookie doesn't grow more when trying to access the same link over and over again
This commit is contained in:
@ -46,7 +46,6 @@ func ShareUpsert(ctx App, res http.ResponseWriter, req *http.Request) {
|
||||
str := ""
|
||||
index := 0
|
||||
for {
|
||||
|
||||
cookie, err := req.Cookie(CookieName(index))
|
||||
if err != nil {
|
||||
break
|
||||
@ -162,7 +161,16 @@ func ShareVerifyProof(ctx App, res http.ResponseWriter, req *http.Request) {
|
||||
|
||||
if submittedProof.Key != "" {
|
||||
submittedProof.Id = Hash(submittedProof.Key+"::"+submittedProof.Value, 20)
|
||||
verifiedProof = append(verifiedProof, submittedProof)
|
||||
alreadyExist := false
|
||||
for i := 0; i < len(verifiedProof); i++ {
|
||||
if verifiedProof[i].Id == submittedProof.Id {
|
||||
alreadyExist = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if alreadyExist == false {
|
||||
verifiedProof = append(verifiedProof, submittedProof)
|
||||
}
|
||||
}
|
||||
|
||||
// 4) Find remaining proofs: requiredProof - verifiedProof
|
||||
|
||||
Reference in New Issue
Block a user