First commit

This commit is contained in:
corrado.mulas
2024-11-20 00:36:19 +01:00
parent 0937f3c06a
commit 1e9cb5ffc4

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"net/http"
"os"
"strings"
)
// RegistrationRequest represents the incoming registration request.
@@ -78,3 +79,24 @@ func registerHandler(w http.ResponseWriter, r *http.Request) {
"message": "User registered successfully. Please check your email to set your password.",
})
}
func validateEmailDomain(email string) bool {
allowedDomains := os.Getenv("ALLOWED_DOMAINS")
if allowedDomains == "" {
return false
}
parts := strings.Split(email, "@")
if len(parts) != 2 {
return false // Invalid email format
}
domain := parts[1]
allowed := strings.Split(allowedDomains, ",")
for _, allowedDomain := range allowed {
if strings.TrimSpace(domain) == strings.TrimSpace(allowedDomain) {
return true
}
}
return false
}