Files
Xor290 22a8d5026c
Frontend Admin - EAS Build / build (push) Canceled after 0s
Frontend Client - EAS Build / build (push) Canceled after 0s
Backend - Build & Lint / build (push) Failing after 25m18s
Frontend Web - Build & Lint / build (push) Failing after 9m58s
chore: build
2026-08-06 12:06:05 +02:00

45 lines
899 B
Go

package utils
import (
"crypto/rand"
"encoding/hex"
"regexp"
"strings"
"github.com/gin-gonic/gin"
)
func GenerateSessionID() string {
bytes := make([]byte, 16)
rand.Read(bytes)
return hex.EncodeToString(bytes)
}
func ValidatePhoneNumber(phone string) bool {
clean := regexp.MustCompile(`[\s\-\(\)]`).ReplaceAllString(phone, "")
validFormat := regexp.MustCompile(`^(\+33|0)[1-9]\d{8}$`)
return validFormat.MatchString(clean)
}
func NormalizePhoneNumber(phone string) string {
clean := regexp.MustCompile(`[\s\-\(\)]`).ReplaceAllString(phone, "")
if strings.HasPrefix(clean, "0") {
return "+33" + clean[1:]
}
return clean
}
func CheckRoleAdmin(c *gin.Context, role string) bool {
return role == "admin"
}
func CheckRoleClient(c *gin.Context, role string) bool {
return role == "client"
}
func CheckRoleCabine(c *gin.Context, role string) bool {
return role == "cabine"
}