Merge remote-tracking branch 'origin/master'

This commit is contained in:
M_Kececi
2026-02-20 15:22:46 +03:00
parent d4583c17d2
commit 50f87e3290
5 changed files with 69 additions and 16 deletions

View File

@@ -2,12 +2,28 @@ package security
import (
"os"
"strings"
)
func BuildResetURL(token string) string {
base := os.Getenv("FRONTEND_URL")
base := os.Getenv("APP_FRONTEND_URL")
if base == "" {
base = os.Getenv("FRONTEND_URL")
}
if base == "" {
base = "http://localhost:9000"
}
return base + "/password-reset/" + token
base = strings.TrimRight(base, "/")
// If base already points to password-reset, just append token if needed.
if strings.Contains(base, "/password-reset") {
if strings.HasSuffix(base, "/password-reset") || strings.HasSuffix(base, "/password-reset/") ||
strings.HasSuffix(base, "/#/password-reset") || strings.HasSuffix(base, "/#/password-reset/") {
return strings.TrimRight(base, "/") + "/" + token
}
return base
}
if strings.Contains(base, "#") {
return base + "/password-reset/" + token
}
return base + "/#/password-reset/" + token
}