fix: 注销后 device login 补回被删除的 device auth_method,修复前端按钮显示异常
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m18s
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m18s
Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
parent
3f56fc6def
commit
772c12f821
@ -96,6 +96,33 @@ func (l *DeviceLoginLogic) DeviceLogin(req *types.DeviceLoginRequest) (resp *typ
|
||||
)
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DatabaseQueryError), "query user failed: %v", err.Error())
|
||||
}
|
||||
|
||||
// 注销后 device auth_method 被删除,重新登录时需要补回
|
||||
hasDeviceAuth := false
|
||||
for _, am := range userInfo.AuthMethods {
|
||||
if am.AuthType == "device" && am.AuthIdentifier == req.Identifier {
|
||||
hasDeviceAuth = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !hasDeviceAuth {
|
||||
authMethod := &user.AuthMethods{
|
||||
UserId: userInfo.Id,
|
||||
AuthType: "device",
|
||||
AuthIdentifier: req.Identifier,
|
||||
Verified: true,
|
||||
}
|
||||
if createErr := l.svcCtx.DB.Create(authMethod).Error; createErr != nil {
|
||||
l.Errorw("re-create device auth method failed",
|
||||
logger.Field("user_id", userInfo.Id),
|
||||
logger.Field("identifier", req.Identifier),
|
||||
logger.Field("error", createErr.Error()),
|
||||
)
|
||||
} else {
|
||||
// 清缓存让后续 FindOne 返回最新 AuthMethods
|
||||
_ = l.svcCtx.UserModel.ClearUserCache(l.ctx, userInfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Generate session id
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user