feat: improve datasource query audit workflows

This commit is contained in:
Logan committed 2026-07-06 23:01:04 +08:00
1 parent 74748e4914
commit 644981eef4
32 files changed
+780 -3061

No files matched your search

+13 -5
View File
@@ -10,6 +10,14 @@ import (
"sql-platform/internal/model"
)
func stringPtr(value string) *string {
return &value
}
func boolPtr(value bool) *bool {
return &value
}
type AuthService struct {
DB *gorm.DB
}
@@ -25,7 +33,7 @@ func (s *AuthService) Login(username, password string) (*model.User, string, err
return nil, "", errors.New("invalid username or password")
}
if !user.IsActive {
if user.IsActive != nil && !*user.IsActive {
return nil, "", errors.New("account is disabled")
}
@@ -33,7 +41,7 @@ func (s *AuthService) Login(username, password string) (*model.User, string, err
return nil, "", errors.New("invalid username or password")
}
token, err := middleware.GenerateToken(user.ID, user.Username, user.Role)
token, err := middleware.GenerateToken(&user)
if err != nil {
return nil, "", errors.New("failed to generate token")
}
@@ -67,11 +75,11 @@ func (s *AuthService) Register(username, displayName, email, phone, password, ro
user := model.User{
Username: username,
DisplayName: displayName,
Email: email,
Phone: phone,
Email: stringPtr(email),
Phone: stringPtr(phone),
HashedPassword: string(hashedPassword),
Role: role,
IsActive: true,
IsActive: boolPtr(true),
}
if err := s.DB.Create(&user).Error; err != nil {