diff --git a/backend/internal/model/user.go b/backend/internal/model/user.go index 33f8095..2726695 100644 --- a/backend/internal/model/user.go +++ b/backend/internal/model/user.go @@ -15,8 +15,9 @@ type User struct { RenterGrowthPoints int64 `gorm:"not null;default:0;index:idx_users_renter_growth_level,priority:2" json:"renter_growth_points"` RenterGrowthLevel string `gorm:"size:32;not null;default:'normal';index:idx_users_renter_growth_level,priority:1" json:"renter_growth_level"` Status string `gorm:"size:32;not null;default:'active'" json:"status"` - // 会话版本:默认与 users.token_version 列默认值保持一致,递增后旧令牌失效。 - TokenVersion int64 `gorm:"not null;default:1" json:"-"` + // 会话版本:递增后该用户已签发的全部令牌立即失效。 + // 默认值对齐迁移 000052 的 users.token_version DEFAULT 0。 + TokenVersion int64 `gorm:"not null;default:0" json:"-"` // 注册归因:注册时由前端携带的推广短码。 RegisterTrackCode string `gorm:"size:64;index:idx_users_register_track_code" json:"register_track_code,omitempty"` LastLoginAt *time.Time `json:"last_login_at"` diff --git a/backend/internal/modules/auth/repository.go b/backend/internal/modules/auth/repository.go index a61f425..4cebfec 100644 --- a/backend/internal/modules/auth/repository.go +++ b/backend/internal/modules/auth/repository.go @@ -83,7 +83,6 @@ func (r *UserRepository) FindOrCreateByPhone(ctx context.Context, phone string, CreditScore: 100, Status: "active", RegisterTrackCode: code, - TokenVersion: 1, LastLoginAt: &now, } @@ -138,7 +137,6 @@ func (r *UserRepository) RegisterWithPassword(ctx context.Context, phone string, CreditScore: 100, Status: "active", RegisterTrackCode: code, - TokenVersion: 1, LastLoginAt: &now, }