small bugfix to random confirmation number

This commit is contained in:
2026-01-06 16:12:22 -07:00
parent 919b58e175
commit ff880603e0
+9 -4
View File
@@ -15,6 +15,8 @@ import (
"io" "io"
mrand "math/rand" mrand "math/rand"
"strings" "strings"
log "github.com/sirupsen/logrus"
) )
// authAlphabet is the set of characters from which we generate auth strings. // authAlphabet is the set of characters from which we generate auth strings.
@@ -25,9 +27,7 @@ const authStringLen = 32
// syllabary is used to generate random passwords. // syllabary is used to generate random passwords.
var syllabary = [...]string{ var syllabary = [...]string{
"ba", "ba", "be", "bi", "bo", "bu",
"be",
"bi", "bo", "bu",
"da", "de", "di", "do", "du", "da", "de", "di", "do", "du",
"cha", "chi", "cho", "chu", "cha", "chi", "cho", "chu",
"fa", "fe", "fi", "fo", "fu", "fa", "fe", "fi", "fo", "fu",
@@ -64,7 +64,12 @@ func GenerateRandomAuthString() string {
// GenerateRandomConfirmationNumber generates a random 7-digit confirmation number. // GenerateRandomConfirmationNumber generates a random 7-digit confirmation number.
func GenerateRandomConfirmationNumber() int32 { func GenerateRandomConfirmationNumber() int32 {
return mrand.Int31n(9000000) + 1000000 rc := mrand.Int31n(9000000) + 1000000
for rc < 1000000 || rc > 9999999 {
log.Errorf("*** GRCN out of range error! %d", rc)
rc = mrand.Int31n(9000000) + 1000000
}
return rc
} }
// GenerateRandomPassword generates a random password string. // GenerateRandomPassword generates a random password string.