feat: add api
docker-publish / publish (push) Failing after 14m14s

This commit is contained in:
Nuxgrid
2026-07-27 16:06:19 +02:00
parent 8397a4470f
commit 6b4274d12b
46 changed files with 3922 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
package auth
import (
"crypto/rand"
"strings"
)
const codeCharset = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789"
// GenerateCode génère un code de 16 caractères alphanumériques,
// regroupés par 4 et séparés par des tirets (ex: "A3F9-K2M7-XQ4R-8ZT1").
func GenerateCode() (string, error) {
const length = 16
const groupSize = 4
b := make([]byte, length)
if _, err := rand.Read(b); err != nil {
return "", err
}
var sb strings.Builder
for i := 0; i < length; i++ {
if i > 0 && i%groupSize == 0 {
sb.WriteByte('-')
}
sb.WriteByte(codeCharset[int(b[i])%len(codeCharset)])
}
return sb.String(), nil
}
func NormalizeUsername(u string) string {
return strings.ToLower(strings.TrimSpace(u))
}