This commit is contained in:
shaoyongjun 2024-08-18 18:24:26 +08:00
parent 60cd363cad
commit 1a938f83c3

View File

@ -4,6 +4,7 @@ import (
"ai-gateway/common/constant"
"ai-gateway/common/dto"
"ai-gateway/common/email"
"ai-gateway/common/logs"
"ai-gateway/common/utils"
"ai-gateway/infrastructure/redis"
"ai-gateway/infrastructure/repository"
@ -49,7 +50,7 @@ func (l login) Register(ctx context.Context, req dto.ThirdRegisterReq) error {
}
func (l login) Login(ctx context.Context, req dto.ThirdLoginReq) (string, error) {
start := time.Now().UnixMilli()
//1. 验证账号密码
h := sha256.Sum256([]byte(req.Password))
passHash := hex.EncodeToString(h[:])
@ -81,6 +82,8 @@ func (l login) Login(ctx context.Context, req dto.ThirdLoginReq) (string, error)
gUserToken.ExpireTime = thirdUserToken.ExpireTime
repository.GUserToken.UpdateUserLoginToken(ctx, gUserToken)
diff := time.Now().UnixMilli() - start
logs.NewLog("").Infof("Login cost: %d", diff)
return l.GenAccessToken(gUserToken), nil
}