implement email verification feature, add captcha validation middleware, and enhance user authentication flow

This commit is contained in:
2025-07-22 08:50:16 +08:00
parent 6187425df6
commit a0d215fa2e
26 changed files with 844 additions and 50 deletions

27
pkg/utils/strings.go Normal file
View File

@ -0,0 +1,27 @@
package utils
import "math/rand"
type stringsUtils struct{}
var Strings = stringsUtils{}
func (s *stringsUtils) GenerateRandomString(length int) string {
const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
result := make([]byte, length)
for i := range result {
result[i] = charset[rand.Intn(len(charset))]
}
return string(result)
}
func (s *stringsUtils) GenerateRandomStringWithCharset(length int, charset string) string {
if charset == "" {
charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
}
result := make([]byte, length)
for i := range result {
result[i] = charset[rand.Intn(len(charset))]
}
return string(result)
}