mirror of
https://github.com/pocketbase/pocketbase.git
synced 2026-10-27 15:30:24 +01:00
[#275] added support to customize the default user email templates from the Admin UI
This commit is contained in:
1 parent
1de56d3d9e
commit
7d10d20de1
47 files changed
+1648
-1188
No files matched your search
@@ -4,15 +4,23 @@ import (
|
||||
"crypto/rand"
|
||||
)
|
||||
|
||||
// RandomString generates a random string of specified length.
|
||||
// RandomString generates a random string with the specified length.
|
||||
//
|
||||
// The generated string is cryptographically random and matches
|
||||
// [A-Za-z0-9]+ (aka. it's transparent to URL-encoding).
|
||||
func RandomString(length int) string {
|
||||
const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
||||
|
||||
return RandomStringWithAlphabet(length, alphabet)
|
||||
}
|
||||
|
||||
// RandomStringWithAlphabet generates a cryptographically random string
|
||||
// with the specified length and characters set.
|
||||
func RandomStringWithAlphabet(length int, alphabet string) string {
|
||||
bytes := make([]byte, length)
|
||||
|
||||
rand.Read(bytes)
|
||||
|
||||
for i, b := range bytes {
|
||||
bytes[i] = alphabet[b%byte(len(alphabet))]
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user