mirror of
https://github.com/ssep1ol/overleaf-registration-be.git
synced 2026-07-21 20:40:21 +00:00
First commit
This commit is contained in:
22
handlers.go
22
handlers.go
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user