From 74f55f43cc97ae9aada28cb3994d6872808b126a Mon Sep 17 00:00:00 2001 From: QiuSW <105186638@qq.com> Date: Thu, 3 Sep 2026 11:16:26 +0800 Subject: [PATCH] =?UTF-8?q?fix(device):=20=E4=BF=AE=E5=A4=8D=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=81=A2=E5=A4=8D=E7=BC=96=E8=AF=91=E9=94=99=E8=AF=AF?= =?UTF-8?q?=20(#201)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/app/goauto/device/service.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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}