feat: 使用双token逻辑
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user