refactor: 清理死代码 + 修复ISP接口注释
- 移除未使用的DTO类型(ChangePasswordRequest/DeleteAccountRequest) - 移除service层未引用的错误重导出(auth_service/audit_service) - 删除未使用的SiteSettingRepo(数据访问由config.SiteSettings直接处理) - 删除未使用的FindByStatus方法(user_repo) - 删除未使用的AutoMigrate方法(audit_repo/notification_repo) - 删除未使用的PaginatedResult/NewPaginatedResult(pagination.go) - 修复接口注释:notifProvider(5→4)、auditUseCase(4→3)、siteSettingUseCase(3→4) - 移除auditStatusProvider未使用的FindByUsername方法 - 统一使用common.ErrXxx直接引用,消除跨service错误重导出耦合
This commit is contained in:
@ -74,24 +74,24 @@ func (ts *TokenService) BuildRefreshToken(user *model.User, rememberMe bool) (st
|
||||
// 校验 token_version:若 DB 中版本已递增,拒绝刷新 → 即时吊销
|
||||
func (ts *TokenService) RefreshAccessToken(refreshTokenStr string) (string, *model.User, error) {
|
||||
if refreshTokenStr == "" {
|
||||
return "", nil, ErrTokenInvalid
|
||||
return "", nil, common.ErrTokenInvalid
|
||||
}
|
||||
|
||||
token, err := jwt.Parse(refreshTokenStr, func(t *jwt.Token) (interface{}, error) {
|
||||
return []byte(ts.cfg.JWT.Secret), nil
|
||||
})
|
||||
if err != nil || !token.Valid {
|
||||
return "", nil, ErrTokenExpired
|
||||
return "", nil, common.ErrTokenExpired
|
||||
}
|
||||
|
||||
claims, ok := token.Claims.(jwt.MapClaims)
|
||||
if !ok {
|
||||
return "", nil, ErrTokenInvalid
|
||||
return "", nil, common.ErrTokenInvalid
|
||||
}
|
||||
|
||||
// 只接受 refresh 用途的 token,防止 access token 被用于刷新
|
||||
if purpose, _ := claims["purpose"].(string); purpose != "refresh" {
|
||||
return "", nil, ErrTokenInvalid
|
||||
return "", nil, common.ErrTokenInvalid
|
||||
}
|
||||
|
||||
uid := uint(claims["uid"].(float64))
|
||||
|
||||
Reference in New Issue
Block a user