2022-01-05 10:44:58 +08:00
|
|
|
|
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
|
|
|
|
|
|
|
|
|
|
|
package userconfigs
|
|
|
|
|
|
|
2022-12-08 20:26:20 +08:00
|
|
|
|
const (
|
2022-12-10 15:54:39 +08:00
|
|
|
|
EmailVerificationDefaultLife = 86400 * 2 // 2 days
|
|
|
|
|
|
EmailResetPasswordDefaultLife = 3600 // 1 hour
|
2022-12-08 20:26:20 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
2022-01-05 10:44:58 +08:00
|
|
|
|
type UserRegisterConfig struct {
|
2022-12-08 20:26:20 +08:00
|
|
|
|
IsOn bool `yaml:"isOn" json:"isOn"` // 是否启用用户注册
|
|
|
|
|
|
ComplexPassword bool `yaml:"complexPassword" json:"complexPassword"` // 必须使用复杂密码
|
|
|
|
|
|
RequireVerification bool `yaml:"requireVerification" json:"requireVerification"` // 是否需要审核
|
|
|
|
|
|
RequireIdentity bool `yaml:"requireIdentity" json:"requireIdentity"` // 是否需要实名认证
|
|
|
|
|
|
|
|
|
|
|
|
// 电子邮箱激活设置
|
|
|
|
|
|
EmailVerification struct {
|
|
|
|
|
|
IsOn bool `yaml:"isOn" json:"isOn"` // 是否启用
|
|
|
|
|
|
ShowNotice bool `yaml:"showNotice" json:"showNotice"` // 提示用户未绑定
|
|
|
|
|
|
Subject string `yaml:"subject" json:"subject"` // 标题
|
|
|
|
|
|
Body string `yaml:"body" json:"body"` // 内容
|
|
|
|
|
|
CanLogin bool `yaml:"canLogin" json:"canLogin"` // 是否可以使用激活的邮箱登录
|
|
|
|
|
|
Life int32 `yaml:"life" json:"life"` // 有效期
|
|
|
|
|
|
} `yaml:"emailVerification" json:"emailVerification"`
|
2022-09-13 19:04:07 +08:00
|
|
|
|
|
2022-12-10 15:54:39 +08:00
|
|
|
|
// 通过邮件找回密码设置
|
|
|
|
|
|
EmailResetPassword struct {
|
|
|
|
|
|
IsOn bool `yaml:"isOn" json:"isOn"` // 是否启用
|
|
|
|
|
|
Subject string `yaml:"subject" json:"subject"` // 标题
|
|
|
|
|
|
Body string `yaml:"body" json:"body"` // 内容
|
|
|
|
|
|
Life int32 `yaml:"life" json:"life"` // 有效期
|
|
|
|
|
|
} `yaml:"emailResetPassword" json:"emailResetPassword"`
|
|
|
|
|
|
|
2022-09-13 19:04:07 +08:00
|
|
|
|
// CDN
|
2022-12-08 20:26:20 +08:00
|
|
|
|
CDNIsOn bool `json:"cdnIsOn"` // 是否开启CDN服务
|
|
|
|
|
|
ClusterId int64 `yaml:"clusterId" json:"clusterId"` // 用户创建服务集群
|
|
|
|
|
|
Features []string `yaml:"features" json:"features"` // 默认启用的功能
|
2022-09-13 19:04:07 +08:00
|
|
|
|
|
|
|
|
|
|
// 开通DNS
|
|
|
|
|
|
NSIsOn bool `json:"nsIsOn"` // 是否开启智能DNS服务
|
2022-01-05 10:44:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func DefaultUserRegisterConfig() *UserRegisterConfig {
|
2022-12-08 20:26:20 +08:00
|
|
|
|
var config = &UserRegisterConfig{
|
2022-01-05 10:44:58 +08:00
|
|
|
|
IsOn: false,
|
|
|
|
|
|
ComplexPassword: true,
|
2022-09-13 19:04:07 +08:00
|
|
|
|
CDNIsOn: true,
|
|
|
|
|
|
NSIsOn: false,
|
2022-01-05 10:44:58 +08:00
|
|
|
|
Features: []string{
|
|
|
|
|
|
UserFeatureCodeServerAccessLog,
|
|
|
|
|
|
UserFeatureCodeServerViewAccessLog,
|
|
|
|
|
|
UserFeatureCodeServerWAF,
|
|
|
|
|
|
UserFeatureCodePlan,
|
|
|
|
|
|
},
|
|
|
|
|
|
RequireVerification: false,
|
|
|
|
|
|
}
|
2022-12-08 20:26:20 +08:00
|
|
|
|
|
2022-12-10 15:54:39 +08:00
|
|
|
|
// 邮箱激活相关
|
2022-12-08 20:26:20 +08:00
|
|
|
|
config.EmailVerification.CanLogin = true
|
|
|
|
|
|
config.EmailVerification.ShowNotice = true
|
|
|
|
|
|
config.EmailVerification.Subject = "【${product.name}】Email地址激活"
|
|
|
|
|
|
config.EmailVerification.Body = `<p>欢迎你使用 ${product.name} 提供的服务,你需要点击以下链接激活你的Email邮箱:</p>
|
|
|
|
|
|
<p><a href="${url.verify}" target="_blank">${url.verify}</a></p>
|
|
|
|
|
|
<p>如果上面内容不是链接形式,请将该地址手工粘贴到浏览器地址栏再访问。</p>
|
|
|
|
|
|
<p></p>
|
|
|
|
|
|
<p>此致</p>
|
|
|
|
|
|
<p>${product.name} 管理团队</p>
|
|
|
|
|
|
<p><a href="${url.home}" target="_blank">${url.home}</a></p>
|
2022-12-10 15:54:39 +08:00
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
|
|
// 通过邮件重置密码相关
|
|
|
|
|
|
config.EmailResetPassword.IsOn = true
|
|
|
|
|
|
config.EmailResetPassword.Subject = "【${product.name}】找回密码"
|
|
|
|
|
|
config.EmailResetPassword.Body = `<p>你正在使用 ${product.name} 提供的找回密码功能,你需要将以下的数字验证码输入到找回密码页面中:</p>
|
|
|
|
|
|
<p><strong>验证码:${code}</strong></p>
|
|
|
|
|
|
<p></p>
|
|
|
|
|
|
<p>${product.name} 管理团队</p>
|
|
|
|
|
|
<p><a href="${url.home}" target="_blank">${url.home}</a></p>
|
2022-12-08 20:26:20 +08:00
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
|
|
return config
|
2022-01-05 10:44:58 +08:00
|
|
|
|
}
|