Implement deletion token hashing

This commit is contained in:
Lukas SP 2020-08-23 16:06:40 +02:00
parent 0fc4ada144
commit cc150b82ac
1 changed files with 10 additions and 1 deletions

View File

@ -75,6 +75,15 @@ func v1PostPaste(ctx *fasthttp.RequestCtx) {
return
}
// Hash the deletion token
pasteCopy := *paste
err = paste.HashDeletionToken()
if err != nil {
ctx.SetStatusCode(fasthttp.StatusInternalServerError)
ctx.SetBodyString(err.Error())
return
}
// Save the paste
err = storage.Current.Save(paste)
if err != nil {
@ -84,7 +93,7 @@ func v1PostPaste(ctx *fasthttp.RequestCtx) {
}
// Respond with the paste
jsonData, err := json.Marshal(paste)
jsonData, err := json.Marshal(pasteCopy)
if err != nil {
ctx.SetStatusCode(fasthttp.StatusInternalServerError)
ctx.SetBodyString(err.Error())