fix(camel_oil): 修正登录校验与登录令牌过期时间

- 将登录校验方法调整为LoginWithIFrameAndLogin以兼容iframe场景
- 修正验证码登录逻辑,区分空令牌和错误
- 更新登录令牌过期时间为30天,延长有效期
- 保持登录令牌状态为可用,并更新最后登录时间
This commit is contained in:
danial
2025-12-09 20:38:06 +08:00
parent fd679be483
commit 4215576170
2 changed files with 5 additions and 8 deletions

View File

@@ -12,7 +12,7 @@ import (
)
func (c *ControllerV1) ListCardBindingsByToken(ctx context.Context, req *v1.ListCardBindingsByTokenReq) (res *v1.ListCardBindingsByTokenRes, err error) {
_, err = service.SysAuth().LoginOnlyLogin(ctx)
_, err = service.SysAuth().LoginWithIFrameAndLogin(ctx)
if err != nil {
err = errHandler.WrapError(ctx, gcode.CodeInternalError, err, "登录校验失败")
return

View File

@@ -489,20 +489,17 @@ func (s *sCamelOil) InputVerificationCode(ctx context.Context, req *model.CamelO
// 使用验证码登录
loginToken, err := client.LoginWithCaptcha(ctx, token.Phone, req.Code)
if err != nil {
// 更新状态为验证码验证失败
_ = s.UpdateTokenStatus(ctx, &model.CamelOilTokenStatusUpdateInput{
TokenId: req.TokenId,
NewStatus: consts.CamelOilTokenStatusVerificationFailed,
Remark: "验证码验证失败",
})
return "", gerror.Wrap(err, "验证码验证失败")
}
if loginToken == "" {
return "", gerror.New("验证码验证失败")
}
// 更新 Token 信息
m := dao.V1CamelOilToken.Ctx(ctx).DB(config.GetDatabaseV1())
_, err = m.Where(dao.V1CamelOilToken.Columns().Id, req.TokenId).Update(&do.V1CamelOilToken{
LoginToken: loginToken,
LoginTokenExpiresAt: gtime.Now().Add(gtime.D * 30), // 24小时后过期
LoginTokenExpiresAt: gtime.Now().Add(gtime.D * 30), // 30天后过期
LastLoginAt: gtime.Now(),
Status: int(consts.CamelOilTokenStatusAvailable), // 可用状态
})