feat: 使用双token逻辑

This commit is contained in:
2026-06-16 16:02:09 +08:00
parent fe1ffd73b2
commit 05ce76ad7a
10 changed files with 237 additions and 15 deletions

View File

@@ -4,6 +4,7 @@ import cn.dev33.satoken.annotation.SaIgnore;
import com.webgame.webgamebackend.common.dto.ApiResponse;
import com.webgame.webgamebackend.common.dto.account.LoginRequest;
import com.webgame.webgamebackend.common.dto.account.LoginResponse;
import com.webgame.webgamebackend.common.dto.account.RefreshTokenRequest;
import com.webgame.webgamebackend.common.dto.account.RegisterRequest;
import com.webgame.webgamebackend.service.AccountService;
import jakarta.validation.Valid;
@@ -44,4 +45,14 @@ public class AccountController {
LoginResponse result = accountService.register(request);
return ApiResponse.ok(result);
}
/**
* 刷新令牌,用 refresh token 换取新的 access token 和 refresh token
*/
@SaIgnore
@PostMapping("/refresh")
public ApiResponse<LoginResponse> refresh(@Valid @RequestBody RefreshTokenRequest request) {
LoginResponse result = accountService.refresh(request.refreshToken());
return ApiResponse.ok(result);
}
}