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

21 lines
474 B
Go

package pastes
import (
"github.com/Lukaesebrot/pasty/internal/env"
"github.com/Lukaesebrot/pasty/internal/utils"
"strconv"
)
// generateDeletionToken generates a new deletion token
func generateDeletionToken() (string, error) {
// Read the deletion token length
rawLength := env.Get("DELETION_TOKEN_LENGTH", "12")
length, err := strconv.Atoi(rawLength)
if err != nil {
return "", err
}
// Generate the deletion token
return utils.RandomString(length), nil
}