refactor: 更新项目引用路径从perfect-panel/ppanel-server到perfect-panel/server
feat: 添加版本和构建时间变量 fix: 修正短信队列类型注释错误 style: 清理未使用的代码和测试文件 docs: 更新安装文档中的下载链接 chore: 迁移数据库脚本添加日志和订阅配置
This commit is contained in:
@@ -3,6 +3,8 @@ package auth
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"github.com/perfect-panel/server/pkg/email"
|
||||
)
|
||||
|
||||
type Auth struct {
|
||||
@@ -124,15 +126,55 @@ type EmailAuthConfig struct {
|
||||
}
|
||||
|
||||
func (l *EmailAuthConfig) Marshal() string {
|
||||
if l.ExpirationEmailTemplate == "" {
|
||||
l.ExpirationEmailTemplate = email.DefaultExpirationEmailTemplate
|
||||
}
|
||||
if l.ExpirationEmailTemplate == "" {
|
||||
l.MaintenanceEmailTemplate = email.DefaultMaintenanceEmailTemplate
|
||||
}
|
||||
if l.TrafficExceedEmailTemplate == "" {
|
||||
l.TrafficExceedEmailTemplate = email.DefaultTrafficExceedEmailTemplate
|
||||
}
|
||||
if l.VerifyEmailTemplate == "" {
|
||||
l.VerifyEmailTemplate = email.DefaultEmailVerifyTemplate
|
||||
}
|
||||
bytes, err := json.Marshal(l)
|
||||
if err != nil {
|
||||
bytes, _ = json.Marshal(new(EmailAuthConfig))
|
||||
config := &EmailAuthConfig{
|
||||
Platform: "smtp",
|
||||
PlatformConfig: new(SMTPConfig),
|
||||
EnableVerify: true,
|
||||
EnableNotify: true,
|
||||
EnableDomainSuffix: false,
|
||||
DomainSuffixList: "",
|
||||
VerifyEmailTemplate: email.DefaultEmailVerifyTemplate,
|
||||
ExpirationEmailTemplate: email.DefaultExpirationEmailTemplate,
|
||||
MaintenanceEmailTemplate: email.DefaultMaintenanceEmailTemplate,
|
||||
TrafficExceedEmailTemplate: email.DefaultTrafficExceedEmailTemplate,
|
||||
}
|
||||
|
||||
bytes, _ = json.Marshal(config)
|
||||
}
|
||||
return string(bytes)
|
||||
}
|
||||
|
||||
func (l *EmailAuthConfig) Unmarshal(data string) error {
|
||||
return json.Unmarshal([]byte(data), &l)
|
||||
func (l *EmailAuthConfig) Unmarshal(data string) {
|
||||
err := json.Unmarshal([]byte(data), &l)
|
||||
if err != nil {
|
||||
config := &EmailAuthConfig{
|
||||
Platform: "smtp",
|
||||
PlatformConfig: new(SMTPConfig),
|
||||
EnableVerify: true,
|
||||
EnableNotify: true,
|
||||
EnableDomainSuffix: false,
|
||||
DomainSuffixList: "",
|
||||
VerifyEmailTemplate: email.DefaultEmailVerifyTemplate,
|
||||
ExpirationEmailTemplate: email.DefaultExpirationEmailTemplate,
|
||||
MaintenanceEmailTemplate: email.DefaultMaintenanceEmailTemplate,
|
||||
TrafficExceedEmailTemplate: email.DefaultTrafficExceedEmailTemplate,
|
||||
}
|
||||
_ = json.Unmarshal([]byte(config.Marshal()), &l)
|
||||
}
|
||||
}
|
||||
|
||||
// SMTPConfig Email SMTP configuration
|
||||
@@ -167,13 +209,28 @@ type MobileAuthConfig struct {
|
||||
func (l *MobileAuthConfig) Marshal() string {
|
||||
bytes, err := json.Marshal(l)
|
||||
if err != nil {
|
||||
bytes, _ = json.Marshal(new(MobileAuthConfig))
|
||||
config := &MobileAuthConfig{
|
||||
Platform: "alibaba_cloud",
|
||||
PlatformConfig: new(AlibabaCloudConfig),
|
||||
EnableWhitelist: false,
|
||||
Whitelist: []string{},
|
||||
}
|
||||
bytes, _ = json.Marshal(config)
|
||||
}
|
||||
return string(bytes)
|
||||
}
|
||||
|
||||
func (l *MobileAuthConfig) Unmarshal(data string) error {
|
||||
return json.Unmarshal([]byte(data), &l)
|
||||
func (l *MobileAuthConfig) Unmarshal(data string) {
|
||||
err := json.Unmarshal([]byte(data), &l)
|
||||
if err != nil {
|
||||
config := &MobileAuthConfig{
|
||||
Platform: "alibaba_cloud",
|
||||
PlatformConfig: new(AlibabaCloudConfig),
|
||||
EnableWhitelist: false,
|
||||
Whitelist: []string{},
|
||||
}
|
||||
_ = json.Unmarshal([]byte(config.Marshal()), &l)
|
||||
}
|
||||
}
|
||||
|
||||
type AlibabaCloudConfig struct {
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/perfect-panel/ppanel-server/pkg/cache"
|
||||
"github.com/perfect-panel/server/pkg/cache"
|
||||
"github.com/redis/go-redis/v9"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user