- 新增 EnableTrialEmailWhitelist + TrialEmailDomainWhitelist 配置 - 邮箱注册/登录:加白名单域名判断,域名匹配才赠送 trial - 设备登录/手机注册:移除 activeTrial,不再自动赠送 - 绑定邮箱(bindEmailWithVerification):绑定成功后检查白名单+防重复赠送 - 新增 IsEmailDomainWhitelisted 导出函数供跨包调用 - 清理 deviceLoginLogic/telephoneUserRegisterLogic 中的 activeTrial 死代码 Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package auth
|
||||
|
||||
import "strings"
|
||||
|
||||
// IsEmailDomainWhitelisted checks if the email's domain is in the comma-separated whitelist.
|
||||
// Returns false if the email format is invalid.
|
||||
func IsEmailDomainWhitelisted(email, whitelistCSV string) bool {
|
||||
if whitelistCSV == "" {
|
||||
return false
|
||||
}
|
||||
parts := strings.SplitN(email, "@", 2)
|
||||
if len(parts) != 2 {
|
||||
return false
|
||||
}
|
||||
domain := strings.ToLower(strings.TrimSpace(parts[1]))
|
||||
for _, d := range strings.Split(whitelistCSV, ",") {
|
||||
if strings.ToLower(strings.TrimSpace(d)) == domain {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
Reference in New Issue
Block a user