1
0
mirror of https://github.com/lus/pasty.git synced 2023-08-10 21:13:09 +03:00

Implement deletion token toggle & master

This commit is contained in:
Lukas Schulte Pelkum
2021-04-20 16:38:00 +02:00
parent f9fc232afe
commit 542bb5b17d
7 changed files with 72 additions and 36 deletions

View File

@@ -36,19 +36,22 @@ func HastebinSupportHandler(ctx *fasthttp.RequestCtx) {
// Create the paste object
paste := &shared.Paste{
ID: id,
Content: content,
DeletionToken: utils.RandomString(config.Current.DeletionTokenLength),
Created: time.Now().Unix(),
AutoDelete: config.Current.AutoDelete.Enabled,
ID: id,
Content: content,
Created: time.Now().Unix(),
AutoDelete: config.Current.AutoDelete.Enabled,
}
// Hash the deletion token
err = paste.HashDeletionToken()
if err != nil {
ctx.SetStatusCode(fasthttp.StatusInternalServerError)
ctx.SetBodyString(err.Error())
return
// Set a deletion token
if config.Current.DeletionTokens {
paste.DeletionToken = utils.RandomString(config.Current.DeletionTokenLength)
err = paste.HashDeletionToken()
if err != nil {
ctx.SetStatusCode(fasthttp.StatusInternalServerError)
ctx.SetBodyString(err.Error())
return
}
}
// Save the paste