refactor: 使用CurrentUser替代OSS中用的Req
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { Controller, Get, Request, UseGuards } from '@nestjs/common';
|
import { Controller, Get, UseGuards } from '@nestjs/common';
|
||||||
import { OssService } from './oss.service';
|
import { OssService } from './oss.service';
|
||||||
import { AuthGuard } from 'src/auth/guards/auth.guard';
|
import { AuthGuard } from 'src/auth/guards/auth.guard';
|
||||||
|
import { AuthUser, CurrentUser } from 'src/auth/decorator/current-user.decorator';
|
||||||
|
|
||||||
@Controller('oss')
|
@Controller('oss')
|
||||||
export class OssController {
|
export class OssController {
|
||||||
@@ -8,8 +9,8 @@ export class OssController {
|
|||||||
|
|
||||||
@UseGuards(AuthGuard)
|
@UseGuards(AuthGuard)
|
||||||
@Get('sts')
|
@Get('sts')
|
||||||
async getStsToken(@Request() req) {
|
async getStsToken(@CurrentUser() user: AuthUser) {
|
||||||
const { userId } = req.user;
|
const { userId } = user;
|
||||||
return {
|
return {
|
||||||
...(await this.ossService.getStsToken(`${userId}`)),
|
...(await this.ossService.getStsToken(`${userId}`)),
|
||||||
userId,
|
userId,
|
||||||
|
|||||||
Reference in New Issue
Block a user