diff --git a/server/app/goauto/device/service.go b/server/app/goauto/device/service.go index b9daed2..2cd2084 100644 --- a/server/app/goauto/device/service.go +++ b/server/app/goauto/device/service.go @@ -259,9 +259,9 @@ func (service *Service) Register(ctx context.Context, request RegisterRequest, p return response, nil } -// ResetIdentity invalidates the current token and grants a short-lived, one-use -// recovery code. The code is returned only to the administrator once; only its -// digest is persisted. It deliberately retains the device row and task bindings. +// ResetIdentity invalidates the current token and opens a short-lived automatic +// re-registration window for the same installId. It retains the device row and +// task bindings, so no recovery code needs to leave the Admin workflow. func (service *Service) ResetIdentity(ctx context.Context, deviceID uint64) (ResetIdentityResponse, error) { if service.DB == nil { return ResetIdentityResponse{}, internalError(errors.New("database is nil")) @@ -269,7 +269,7 @@ func (service *Service) ResetIdentity(ctx context.Context, deviceID uint64) (Res now := service.Now() expiresAt := now.Add(deviceRecoveryLifetime) response := ResetIdentityResponse{DeviceID: deviceID, ExpiresAt: expiresAt} - err = service.DB.WithContext(ctx).Transaction(func(tx *gorm.DB) error { + err := service.DB.WithContext(ctx).Transaction(func(tx *gorm.DB) error { var device models.AgentDevice if err := tx.First(&device, deviceID).Error; errors.Is(err, gorm.ErrRecordNotFound) { return &ServiceError{Code: CodeDeviceNotFound, Message: "设备不存在", Retryable: false}