introduce the password reminder infrastructure

This commit is contained in:
2025-10-06 16:42:23 -06:00
parent 33c2fcc471
commit fe360e23d3
4 changed files with 41 additions and 12 deletions
+8 -2
View File
@@ -11,8 +11,9 @@
package util
import (
"crypto/rand"
crand "crypto/rand"
"io"
mrand "math/rand"
)
// authAlphabet is the set of characters from which we generate auth strings.
@@ -24,7 +25,7 @@ const authStringLen = 32
// GenerateRandomAuthString generates a random authentication string.
func GenerateRandomAuthString() string {
b := make([]byte, authStringLen)
if _, err := io.ReadFull(rand.Reader, b); err != nil {
if _, err := io.ReadFull(crand.Reader, b); err != nil {
// can't happen (at least on a modern OS)
panic("failed to read random: " + err.Error())
}
@@ -33,3 +34,8 @@ func GenerateRandomAuthString() string {
}
return string(b)
}
// GenerateRandomConfirmationNumber generates a random 7-digit confirmation number.
func GenerateRandomConfirmationNumber() int32 {
return mrand.Int31n(9000000) + 1000000
}