2020-08-23 00:24:38 +03:00
|
|
|
package pastes
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/Lukaesebrot/pasty/internal/env"
|
2020-08-24 21:22:53 +03:00
|
|
|
"github.com/Lukaesebrot/pasty/internal/utils"
|
2020-08-23 00:24:38 +03:00
|
|
|
"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
|
2020-08-24 21:22:53 +03:00
|
|
|
return utils.RandomString(length), nil
|
2020-08-23 00:24:38 +03:00
|
|
|
}
|