Skip to content

Commit

Permalink
Delete guest tokens after usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Kwonunn committed Jun 16, 2024
1 parent 373d9d1 commit e51eb1d
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions internal/webserver/fileupload/FileUpload.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package fileupload

import (
"io"
"net/http"
"strconv"
"time"

"github.com/forceu/gokapi/internal/configuration"
"github.com/forceu/gokapi/internal/configuration/database"
"github.com/forceu/gokapi/internal/models"
"github.com/forceu/gokapi/internal/storage"
"github.com/forceu/gokapi/internal/storage/chunking"
"io"
"net/http"
"strconv"
"time"
"github.com/forceu/gokapi/internal/webserver/guestupload"
)

// Process processes a file upload request
Expand Down Expand Up @@ -83,6 +85,13 @@ func CompleteChunk(w http.ResponseWriter, r *http.Request, isApiCall bool) error
return err
}
_, _ = io.WriteString(w, result.ToJsonResult(config.ExternalUrl))

// If an UploadToken was used, delete it
tokens, ok := r.URL.Query()["token"]
if ok && guestupload.IsValidUploadToken(tokens[0]) {
guestupload.DeleteUploadToken(tokens[0])
}

return nil
}

Expand Down

0 comments on commit e51eb1d

Please sign in to comment.