mirror of
https://github.com/mickael-kerjean/filestash.git
synced 2025-10-30 17:46:41 +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 := ""
|
str := ""
|
||||||
index := 0
|
index := 0
|
||||||
for {
|
for {
|
||||||
|
|
||||||
cookie, err := req.Cookie(CookieName(index))
|
cookie, err := req.Cookie(CookieName(index))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
break
|
break
|
||||||
@ -162,8 +161,17 @@ func ShareVerifyProof(ctx App, res http.ResponseWriter, req *http.Request) {
|
|||||||
|
|
||||||
if submittedProof.Key != "" {
|
if submittedProof.Key != "" {
|
||||||
submittedProof.Id = Hash(submittedProof.Key+"::"+submittedProof.Value, 20)
|
submittedProof.Id = Hash(submittedProof.Key+"::"+submittedProof.Value, 20)
|
||||||
|
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)
|
verifiedProof = append(verifiedProof, submittedProof)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 4) Find remaining proofs: requiredProof - verifiedProof
|
// 4) Find remaining proofs: requiredProof - verifiedProof
|
||||||
remainingProof = model.ShareProofCalculateRemainings(requiredProof, verifiedProof)
|
remainingProof = model.ShareProofCalculateRemainings(requiredProof, verifiedProof)
|
||||||
|
|||||||
Reference in New Issue
Block a user