fix(auth): 终端用户口令改 bcrypt,兼容历史明文自动升级
Docker Build / Build and Push Docker Image (push) Successful in 29s
Docker Build / Deploy to Server (push) Successful in 3s

- 新增 service.VerifyAppUserPassword:bcrypt 直接比对;明文定长比较,命中后条件更新升级为 bcrypt(WHERE password=旧值,避免并发覆盖)
- 登录、解绑设备鉴权、修改口令三处统一走该函数
- 注册与改密的新口令入库前 bcrypt 哈希(此前注册写明文、重置写哈希,库里是混合状态)
- 实测:明文用户首次登录成功并落库为 $2a$ 哈希;二次登录走 bcrypt;错误口令拒绝;新注册与改密均为哈希
This commit is contained in:
hermes
2026-11-21 21:22:36 +08:00
parent 5169bf249e
commit 80bc105d95
9 changed files with 323 additions and 187 deletions
+43 -38
View File
@@ -199,16 +199,16 @@ func handleAppRegister(c *gin.Context) {
}
var req struct {
Username string `json:"username"`
Email string `json:"email"`
EmailCode string `json:"email_code"`
Phone string `json:"phone"`
SmsCode string `json:"sms_code"`
Password string `json:"password"`
DeviceID string `json:"device_id"`
DeviceName string `json:"device_name"`
DeviceType string `json:"device_type"`
InstanceID string `json:"instance_id"`
Username string `json:"username"`
Email string `json:"email"`
EmailCode string `json:"email_code"`
Phone string `json:"phone"`
SmsCode string `json:"sms_code"`
Password string `json:"password"`
DeviceID string `json:"device_id"`
DeviceName string `json:"device_name"`
DeviceType string `json:"device_type"`
InstanceID string `json:"instance_id"`
}
if err := c.ShouldBindJSON(&req); err != nil {
log.Printf("[DEBUG] Invalid request parameters: %v", err)
@@ -294,10 +294,15 @@ func handleAppRegister(c *gin.Context) {
return
}
hashedPwd, hashErr := service.HashAppUserPassword(req.Password)
if hashErr != nil {
response.Error(c, 500, "注册失败:口令处理出错")
return
}
user = model.AppUser{
Username: req.Username,
Email: req.Email,
Password: req.Password,
Password: hashedPwd,
DeviceID: req.DeviceID,
Avatar: "",
Status: "active",
@@ -437,7 +442,7 @@ func handleAppLogin(c *gin.Context) {
return
}
if user.Password != req.Password {
if !service.VerifyAppUserPassword(&user, req.Password) {
log.Printf("[DEBUG] Password mismatch for user: %s", req.Username)
service.LogVerification(c, &appModel.ID, &user.ID, "login_failed", "登录失败: 密码错误 - "+req.Username, req.DeviceID, fmt.Errorf("密码错误"))
response.Error(c, 400, "密码错误")
@@ -500,7 +505,7 @@ func handleAppLogin(c *gin.Context) {
now := time.Now()
deviceType := getDeviceType(c, req.DeviceType)
deviceName := req.DeviceName
if deviceName == "" {
deviceName = req.DeviceID
@@ -520,10 +525,10 @@ func handleAppLogin(c *gin.Context) {
if appModel.MaxDevices > 0 && ipCount >= int64(appModel.MaxDevices) {
log.Printf("[DEBUG] IP limit exceeded for user %d: %d/%d", user.ID, ipCount, appModel.MaxDevices)
var userIPs []model.UserIP
database.DB.Where("user_id = ? AND application_id = ?", user.ID, appModel.ID).Order("created_at DESC").Find(&userIPs)
ipList := make([]gin.H, 0)
for _, ip := range userIPs {
ipList = append(ipList, gin.H{
@@ -533,12 +538,12 @@ func handleAppLogin(c *gin.Context) {
"created_at": ip.CreatedAt,
})
}
response.ErrorWithData(c, 403, "IP绑定数量已达上限,请解绑后再试", gin.H{
"error_code": "IP_LIMIT_EXCEEDED",
"max_ips": appModel.MaxDevices,
"ip_count": ipCount,
"ips": ipList,
"error_code": "IP_LIMIT_EXCEEDED",
"max_ips": appModel.MaxDevices,
"ip_count": ipCount,
"ips": ipList,
})
service.LogVerification(c, &appModel.ID, &user.ID, "login_failed", "登录失败: IP绑定数量已达上限 - "+req.Username, req.DeviceID, fmt.Errorf("IP绑定数量已达上限"))
return
@@ -557,7 +562,7 @@ func handleAppLogin(c *gin.Context) {
}
}
}
var device model.UserDevice
deviceErr := database.DB.Where("user_id = ? AND application_id = ? AND device_id = ?", user.ID, appModel.ID, req.DeviceID).First(&device).Error
@@ -570,25 +575,25 @@ func handleAppLogin(c *gin.Context) {
if deviceCount >= int64(appModel.MaxDevices) {
log.Printf("[DEBUG] Device limit exceeded for user %d: %d/%d", user.ID, deviceCount, appModel.MaxDevices)
var devices []model.UserDevice
database.DB.Where("user_id = ? AND application_id = ?", user.ID, appModel.ID).Order("created_at DESC").Find(&devices)
deviceList := make([]gin.H, 0)
for _, d := range devices {
var onlineSessions []model.DeviceSession
database.DB.Where("device_id = ? AND last_heartbeat > ?", d.ID, timeoutThreshold).Find(&onlineSessions)
deviceList = append(deviceList, gin.H{
"id": d.ID,
"device_id": d.DeviceID,
"device_name": d.DeviceName,
"device_type": d.DeviceType,
"online_count": len(onlineSessions),
"created_at": d.CreatedAt,
"id": d.ID,
"device_id": d.DeviceID,
"device_name": d.DeviceName,
"device_type": d.DeviceType,
"online_count": len(onlineSessions),
"created_at": d.CreatedAt,
})
}
response.ErrorWithData(c, 403, "设备绑定数量已达上限,请解绑后再试", gin.H{
"error_code": "DEVICE_LIMIT_EXCEEDED",
"max_devices": appModel.MaxDevices,
@@ -599,7 +604,7 @@ func handleAppLogin(c *gin.Context) {
return
}
}
device = model.UserDevice{
UserID: user.ID,
ApplicationID: appModel.ID,
@@ -629,10 +634,10 @@ func handleAppLogin(c *gin.Context) {
if sessionCount >= int64(appModel.MaxInstances) {
log.Printf("[DEBUG] Multi-instance limit exceeded for user %d device %s: %d/%d", user.ID, req.DeviceID, sessionCount, appModel.MaxInstances)
var sessions []model.DeviceSession
database.DB.Where("device_id = ? AND instance_id != ?", device.ID, instanceID).Order("last_heartbeat DESC").Find(&sessions)
sessionList := make([]gin.H, 0)
for _, s := range sessions {
isOnline := s.LastHeartbeat != nil && s.LastHeartbeat.After(timeoutThreshold)
@@ -644,7 +649,7 @@ func handleAppLogin(c *gin.Context) {
"created_at": s.CreatedAt,
})
}
response.ErrorWithData(c, 403, "多开数量已达上限", gin.H{
"error_code": "MULTI_INSTANCE_LIMIT_EXCEEDED",
"max_instances": appModel.MaxInstances,
@@ -899,9 +904,9 @@ func handleAppResetPassword(c *gin.Context) {
}
var req struct {
Email string `json:"email" binding:"required,email"`
Code string `json:"code" binding:"required"`
Password string `json:"password" binding:"required,min=6"`
Email string `json:"email" binding:"required,email"`
Code string `json:"code" binding:"required"`
Password string `json:"password" binding:"required,min=6"`
}
if err := c.ShouldBindJSON(&req); err != nil {
response.Error(c, 400, "参数错误")
+15 -10
View File
@@ -58,7 +58,7 @@ func handleAppUnbindDeviceWithAuth(c *gin.Context) {
return
}
if user.Password != req.Password {
if !service.VerifyAppUserPassword(&user, req.Password) {
response.Error(c, 401, "密码错误")
return
}
@@ -125,13 +125,13 @@ func handleAppGetDevices(c *gin.Context) {
Count(&onlineSessionCount)
result = append(result, gin.H{
"id": device.ID,
"device_id": device.DeviceID,
"device_name": device.DeviceName,
"device_type": device.DeviceType,
"status": device.Status,
"online_sessions": onlineSessionCount,
"created_at": device.CreatedAt,
"id": device.ID,
"device_id": device.DeviceID,
"device_name": device.DeviceName,
"device_type": device.DeviceType,
"status": device.Status,
"online_sessions": onlineSessionCount,
"created_at": device.CreatedAt,
})
}
@@ -373,12 +373,17 @@ func handleAppChangePassword(c *gin.Context) {
return
}
if user.Password != req.OldPassword {
if !service.VerifyAppUserPassword(&user, req.OldPassword) {
response.Error(c, 400, "原密码错误")
return
}
user.Password = req.NewPassword
newHash, hashErr := service.HashAppUserPassword(req.NewPassword)
if hashErr != nil {
response.Error(c, 500, "密码修改失败")
return
}
user.Password = newHash
if err := database.DB.Save(&user).Error; err != nil {
response.Error(c, 500, "密码修改失败")
return
+49 -49
View File
@@ -121,40 +121,40 @@ func handleExecuteDynamicCode(c *gin.Context) {
vm := goja.New()
appData := map[string]interface{}{
"id": app.ID,
"name": app.Name,
"description": app.Description,
"app_key": app.AppKey,
"status": app.Status,
"billing_type": app.BillingType,
"deduction_mode": app.DeductionMode,
"deduction_type": app.DeductionType,
"deduction_interval": app.DeductionInterval,
"deduction_unit": app.DeductionUnit,
"deduction_amount": app.DeductionAmount,
"enable_trial": app.EnableTrial,
"trial_balance": app.TrialBalance,
"trial_days": app.TrialDays,
"enable_free_period": app.EnableFreePeriod,
"free_period_type": app.FreePeriodType,
"free_period_start": app.FreePeriodStart,
"free_period_end": app.FreePeriodEnd,
"free_period_weekdays": app.FreePeriodWeekdays,
"id": app.ID,
"name": app.Name,
"description": app.Description,
"app_key": app.AppKey,
"status": app.Status,
"billing_type": app.BillingType,
"deduction_mode": app.DeductionMode,
"deduction_type": app.DeductionType,
"deduction_interval": app.DeductionInterval,
"deduction_unit": app.DeductionUnit,
"deduction_amount": app.DeductionAmount,
"enable_trial": app.EnableTrial,
"trial_balance": app.TrialBalance,
"trial_days": app.TrialDays,
"enable_free_period": app.EnableFreePeriod,
"free_period_type": app.FreePeriodType,
"free_period_start": app.FreePeriodStart,
"free_period_end": app.FreePeriodEnd,
"free_period_weekdays": app.FreePeriodWeekdays,
"free_period_start_time": app.FreePeriodStartTime,
"free_period_end_time": app.FreePeriodEndTime,
"max_devices": app.MaxDevices,
"bind_type": app.BindType,
"multi_open_mode": app.MultiOpenMode,
"max_instances": app.MaxInstances,
"login_policy": app.LoginPolicy,
"max_attempts": app.MaxAttempts,
"lock_duration": app.LockDuration,
"heartbeat_interval": app.HeartbeatInterval,
"heartbeat_timeout": app.HeartbeatTimeout,
"change_limit": app.ChangeLimit,
"change_interval": app.ChangeInterval,
"change_exceed_action": app.ChangeExceedAction,
"change_deduct_amount": app.ChangeDeductAmount,
"free_period_end_time": app.FreePeriodEndTime,
"max_devices": app.MaxDevices,
"bind_type": app.BindType,
"multi_open_mode": app.MultiOpenMode,
"max_instances": app.MaxInstances,
"login_policy": app.LoginPolicy,
"max_attempts": app.MaxAttempts,
"lock_duration": app.LockDuration,
"heartbeat_interval": app.HeartbeatInterval,
"heartbeat_timeout": app.HeartbeatTimeout,
"change_limit": app.ChangeLimit,
"change_interval": app.ChangeInterval,
"change_exceed_action": app.ChangeExceedAction,
"change_deduct_amount": app.ChangeDeductAmount,
}
if err := vm.Set("app", appData); err != nil {
response.Error(c, 500, "应用数据设置失败")
@@ -216,12 +216,12 @@ func handleExecuteDynamicCode(c *gin.Context) {
database.DB.Where("user_id = ? AND application_id = ?", user.ID, app.ID).Find(&userDevices)
for _, d := range userDevices {
devices = append(devices, map[string]interface{}{
"id": d.ID,
"device_id": d.DeviceID,
"device_name": d.DeviceName,
"device_type": d.DeviceType,
"status": d.Status,
"created_at": d.CreatedAt,
"id": d.ID,
"device_id": d.DeviceID,
"device_name": d.DeviceName,
"device_type": d.DeviceType,
"status": d.Status,
"created_at": d.CreatedAt,
})
}
@@ -266,12 +266,12 @@ func handleExecuteDynamicCode(c *gin.Context) {
database.DB.Where("user_id = ? AND application_id = ?", targetUser.ID, app.ID).Find(&targetUserDevices)
for _, d := range targetUserDevices {
targetDevices = append(targetDevices, map[string]interface{}{
"id": d.ID,
"device_id": d.DeviceID,
"device_name": d.DeviceName,
"device_type": d.DeviceType,
"status": d.Status,
"created_at": d.CreatedAt,
"id": d.ID,
"device_id": d.DeviceID,
"device_name": d.DeviceName,
"device_type": d.DeviceType,
"status": d.Status,
"created_at": d.CreatedAt,
})
}
@@ -669,10 +669,10 @@ func handleAddRecord(appID uint, userID *uint, actionMap map[string]interface{})
func getRecords(appID uint, userID *uint, variableKey string, page, pageSize int) map[string]interface{} {
result := map[string]interface{}{
"success": false,
"records": []interface{}{},
"total": 0,
"page": page,
"success": false,
"records": []interface{}{},
"total": 0,
"page": page,
"pageSize": pageSize,
}
+1 -1
View File
@@ -203,7 +203,7 @@ func handleAppTrial(c *gin.Context) {
}
response.SuccessWithMessage(c, "试用成功", gin.H{
"message": "试用成功",
"message": "试用成功",
"trial_balance": app.TrialBalance,
})
}
+5 -5
View File
@@ -116,11 +116,11 @@ func handleAppGetUserInfo(c *gin.Context) {
}
result := gin.H{
"user_id": user.ID,
"username": user.Username,
"email": user.Email,
"avatar": user.Avatar,
"status": user.Status,
"user_id": user.ID,
"username": user.Username,
"email": user.Email,
"avatar": user.Avatar,
"status": user.Status,
}
if user.Balance == -1 {
@@ -0,0 +1,55 @@
package service
import (
"crypto/subtle"
"log"
"strings"
"verification-platform-backend/internal/database"
"verification-platform-backend/internal/model"
"golang.org/x/crypto/bcrypt"
)
// IsBcryptHash 判断库里的口令字段是不是 bcrypt 哈希
func IsBcryptHash(s string) bool {
return strings.HasPrefix(s, "$2a$") || strings.HasPrefix(s, "$2b$") || strings.HasPrefix(s, "$2y$")
}
// HashAppUserPassword 终端用户新口令入库前的统一哈希
func HashAppUserPassword(plain string) (string, error) {
h, err := bcrypt.GenerateFromPassword([]byte(plain), bcrypt.DefaultCost)
return string(h), err
}
// VerifyAppUserPassword 校验终端用户口令,兼容历史明文
//
// 历史原因 app_users.password 里混着明文和 bcrypt(注册写明文、重置写哈希)。
// 这里两条都认:bcrypt 直接比对;明文用定长比较,命中后顺手升级成 bcrypt。
// 升级用 WHERE password = 旧值 做条件更新,避免并发把别人刚写的哈希覆盖回去。
// 升级写库失败不影响本次登录结果——放行,等下次再升。
func VerifyAppUserPassword(user *model.AppUser, plain string) bool {
if user == nil || user.Password == "" {
return false
}
if IsBcryptHash(user.Password) {
return bcrypt.CompareHashAndPassword([]byte(user.Password), []byte(plain)) == nil
}
if subtle.ConstantTimeCompare([]byte(user.Password), []byte(plain)) != 1 {
return false
}
h, err := HashAppUserPassword(plain)
if err != nil {
log.Printf("[appuser] 口令升级失败 user=%d: %v", user.ID, err)
return true
}
res := database.DB.Model(&model.AppUser{}).
Where("id = ? AND password = ?", user.ID, user.Password).
Update("password", h)
if res.Error != nil {
log.Printf("[appuser] 口令升级写库失败 user=%d: %v", user.ID, res.Error)
return true
}
user.Password = h
return true
}
@@ -0,0 +1,71 @@
package service
import (
"testing"
"verification-platform-backend/internal/model"
"golang.org/x/crypto/bcrypt"
)
func TestHashAndVerifyAppUserPassword(t *testing.T) {
h, err := HashAppUserPassword("123456")
if err != nil {
t.Fatalf("哈希失败: %v", err)
}
if !IsBcryptHash(h) {
t.Fatalf("哈希前缀不识别: %s", h[:7])
}
u := &model.AppUser{Password: h}
if !VerifyAppUserPassword(u, "123456") {
t.Fatal("正确口令未通过")
}
if VerifyAppUserPassword(u, "1234567") {
t.Fatal("错误口令通过了")
}
if VerifyAppUserPassword(nil, "123456") {
t.Fatal("nil 用户通过了")
}
if VerifyAppUserPassword(&model.AppUser{}, "x") {
t.Fatal("空口令用户通过了")
}
}
// 历史明文必须仍然认账(这里只测比对分支:口令不符时不触发写库)
func TestVerifyLegacyPlaintextMismatch(t *testing.T) {
u := &model.AppUser{Password: "plain-old"}
if VerifyAppUserPassword(u, "wrong") {
t.Fatal("明文错误口令通过了")
}
if IsBcryptHash("plain-old") {
t.Fatal("明文被误判成 bcrypt")
}
}
func TestIsBcryptHash(t *testing.T) {
cases := map[string]bool{
"$2a$10$abc": true,
"$2b$12$xyz": true,
"$2y$05$q": true,
"123456": false,
"": false,
"$2a": false,
}
for in, want := range cases {
if got := IsBcryptHash(in); got != want {
t.Fatalf("IsBcryptHash(%q)=%v 期望 %v", in, got, want)
}
}
}
func TestBcryptRoundTripCost(t *testing.T) {
// 成本不能被误改成 4 以下
h, err := bcrypt.GenerateFromPassword([]byte("x"), bcrypt.DefaultCost)
if err != nil {
t.Fatal(err)
}
c, err := bcrypt.Cost(h)
if err != nil || c != bcrypt.DefaultCost {
t.Fatalf("成本 %v 期望 %v (err=%v)", c, bcrypt.DefaultCost, err)
}
}
+7 -7
View File
@@ -56,13 +56,13 @@ func (s *AuthService) Login(username, password, agentPath string) (map[string]in
// 返回用户信息和令牌
return map[string]interface{}{
"user": map[string]interface{}{
"id": user.ID,
"username": user.Username,
"email": user.Email,
"avatar": user.Avatar,
"role": user.Role,
"status": user.Status,
"parent_agent_id": user.ParentAgentID,
"id": user.ID,
"username": user.Username,
"email": user.Email,
"avatar": user.Avatar,
"role": user.Role,
"status": user.Status,
"parent_agent_id": user.ParentAgentID,
"can_view_cloud_data": user.CanViewCloudData,
},
"token": token,
+77 -77
View File
@@ -66,46 +66,46 @@ func GetApplicationDisabledStatus(appID uint) bool {
}
type ApplicationWithStatus struct {
ID uint `json:"id"`
UserID uint `json:"user_id"`
Name string `json:"name"`
Description string `json:"description"`
AppKey string `json:"app_key"`
IconURL string `json:"icon_url"`
Status string `json:"status"`
BillingType string `json:"billing_type"`
LoginPolicy string `json:"login_policy"`
MaxDevices int `json:"max_devices"`
MultiOpenMode string `json:"multi_open_mode"`
EnableTrial bool `json:"enable_trial"`
TrialDays int `json:"trial_days"`
EnableFreePeriod bool `json:"enable_free_period"`
FreePeriodType string `json:"free_period_type"`
FreePeriodStart string `json:"free_period_start"`
FreePeriodEnd string `json:"free_period_end"`
FreePeriodWeekdays string `json:"free_period_weekdays"`
FreePeriodStartTime string `json:"free_period_start_time"`
FreePeriodEndTime string `json:"free_period_end_time"`
HeartbeatInterval int `json:"heartbeat_interval"`
HeartbeatTimeout int `json:"heartbeat_timeout"`
MaxAttempts int `json:"max_attempts"`
LockDuration int `json:"lock_duration"`
DeductionMode string `json:"deduction_mode"`
DeductionType string `json:"deduction_type"`
DeductionInterval int `json:"deduction_interval"`
DeductionUnit string `json:"deduction_unit"`
DeductionAmount float64 `json:"deduction_amount"`
AllowRegister bool `json:"allow_register"`
EnableLoginVerify bool `json:"enable_login_verify"`
EnableRegisterVerify bool `json:"enable_register_verify"`
VerifyMethod string `json:"verify_method"`
EnablePasswordReset bool `json:"enable_password_reset"`
PasswordResetMethod string `json:"password_reset_method"`
PasswordResetEmailID *uint `json:"password_reset_email_id"`
PasswordResetSmsID *uint `json:"password_reset_sms_id"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
DisabledByPackage bool `json:"disabled_by_package"`
ID uint `json:"id"`
UserID uint `json:"user_id"`
Name string `json:"name"`
Description string `json:"description"`
AppKey string `json:"app_key"`
IconURL string `json:"icon_url"`
Status string `json:"status"`
BillingType string `json:"billing_type"`
LoginPolicy string `json:"login_policy"`
MaxDevices int `json:"max_devices"`
MultiOpenMode string `json:"multi_open_mode"`
EnableTrial bool `json:"enable_trial"`
TrialDays int `json:"trial_days"`
EnableFreePeriod bool `json:"enable_free_period"`
FreePeriodType string `json:"free_period_type"`
FreePeriodStart string `json:"free_period_start"`
FreePeriodEnd string `json:"free_period_end"`
FreePeriodWeekdays string `json:"free_period_weekdays"`
FreePeriodStartTime string `json:"free_period_start_time"`
FreePeriodEndTime string `json:"free_period_end_time"`
HeartbeatInterval int `json:"heartbeat_interval"`
HeartbeatTimeout int `json:"heartbeat_timeout"`
MaxAttempts int `json:"max_attempts"`
LockDuration int `json:"lock_duration"`
DeductionMode string `json:"deduction_mode"`
DeductionType string `json:"deduction_type"`
DeductionInterval int `json:"deduction_interval"`
DeductionUnit string `json:"deduction_unit"`
DeductionAmount float64 `json:"deduction_amount"`
AllowRegister bool `json:"allow_register"`
EnableLoginVerify bool `json:"enable_login_verify"`
EnableRegisterVerify bool `json:"enable_register_verify"`
VerifyMethod string `json:"verify_method"`
EnablePasswordReset bool `json:"enable_password_reset"`
PasswordResetMethod string `json:"password_reset_method"`
PasswordResetEmailID *uint `json:"password_reset_email_id"`
PasswordResetSmsID *uint `json:"password_reset_sms_id"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
DisabledByPackage bool `json:"disabled_by_package"`
}
func GetApplicationsWithDisabledStatus(userID uint) ([]ApplicationWithStatus, error) {
@@ -122,45 +122,45 @@ func GetApplicationsWithDisabledStatus(userID uint) ([]ApplicationWithStatus, er
result := make([]ApplicationWithStatus, len(apps))
for i, app := range apps {
result[i] = ApplicationWithStatus{
ID: app.ID,
UserID: app.UserID,
Name: app.Name,
Description: app.Description,
AppKey: app.AppKey,
IconURL: app.IconURL,
Status: app.Status,
BillingType: app.BillingType,
LoginPolicy: app.LoginPolicy,
MaxDevices: app.MaxDevices,
MultiOpenMode: app.MultiOpenMode,
EnableTrial: app.EnableTrial,
TrialDays: app.TrialDays,
EnableFreePeriod: app.EnableFreePeriod,
FreePeriodType: app.FreePeriodType,
FreePeriodStart: app.FreePeriodStart,
FreePeriodEnd: app.FreePeriodEnd,
FreePeriodWeekdays: app.FreePeriodWeekdays,
FreePeriodStartTime: app.FreePeriodStartTime,
FreePeriodEndTime: app.FreePeriodEndTime,
HeartbeatInterval: app.HeartbeatInterval,
HeartbeatTimeout: app.HeartbeatTimeout,
MaxAttempts: app.MaxAttempts,
LockDuration: app.LockDuration,
DeductionMode: app.DeductionMode,
DeductionType: app.DeductionType,
DeductionInterval: app.DeductionInterval,
DeductionUnit: app.DeductionUnit,
DeductionAmount: app.DeductionAmount,
AllowRegister: app.AllowRegister,
EnableLoginVerify: app.EnableLoginVerify,
ID: app.ID,
UserID: app.UserID,
Name: app.Name,
Description: app.Description,
AppKey: app.AppKey,
IconURL: app.IconURL,
Status: app.Status,
BillingType: app.BillingType,
LoginPolicy: app.LoginPolicy,
MaxDevices: app.MaxDevices,
MultiOpenMode: app.MultiOpenMode,
EnableTrial: app.EnableTrial,
TrialDays: app.TrialDays,
EnableFreePeriod: app.EnableFreePeriod,
FreePeriodType: app.FreePeriodType,
FreePeriodStart: app.FreePeriodStart,
FreePeriodEnd: app.FreePeriodEnd,
FreePeriodWeekdays: app.FreePeriodWeekdays,
FreePeriodStartTime: app.FreePeriodStartTime,
FreePeriodEndTime: app.FreePeriodEndTime,
HeartbeatInterval: app.HeartbeatInterval,
HeartbeatTimeout: app.HeartbeatTimeout,
MaxAttempts: app.MaxAttempts,
LockDuration: app.LockDuration,
DeductionMode: app.DeductionMode,
DeductionType: app.DeductionType,
DeductionInterval: app.DeductionInterval,
DeductionUnit: app.DeductionUnit,
DeductionAmount: app.DeductionAmount,
AllowRegister: app.AllowRegister,
EnableLoginVerify: app.EnableLoginVerify,
EnableRegisterVerify: app.EnableRegisterVerify,
VerifyMethod: app.VerifyMethod,
EnablePasswordReset: app.EnablePasswordReset,
PasswordResetMethod: app.PasswordResetMethod,
VerifyMethod: app.VerifyMethod,
EnablePasswordReset: app.EnablePasswordReset,
PasswordResetMethod: app.PasswordResetMethod,
PasswordResetEmailID: app.PasswordResetEmailID,
PasswordResetSmsID: app.PasswordResetSmsID,
CreatedAt: app.CreatedAt.Format("2006-01-02T15:04:05Z07:00"),
UpdatedAt: app.UpdatedAt.Format("2006-01-02T15:04:05Z07:00"),
PasswordResetSmsID: app.PasswordResetSmsID,
CreatedAt: app.CreatedAt.Format("2006-01-02T15:04:05Z07:00"),
UpdatedAt: app.UpdatedAt.Format("2006-01-02T15:04:05Z07:00"),
}
}