mirror of
https://github.com/lus/pasty.git
synced 2023-08-10 21:13:09 +03:00
21 lines
474 B
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
|
|
}
|