pasty/internal/pastes/deletion_token.go

22 lines
459 B
Go

package pastes
import (
"strconv"
"github.com/lus/pasty/internal/env"
"github.com/lus/pasty/internal/utils"
)
// 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
}