feat(mining-admin-service): 添加/auth/profile接口
前端dashboard layout需要获取当前用户信息,添加GET /auth/profile接口 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
86f2c85f8d
commit
25ad627377
|
|
@ -1,4 +1,4 @@
|
||||||
import { Controller, Post, Body, Req, HttpCode, HttpStatus } from '@nestjs/common';
|
import { Controller, Post, Get, Body, Req, HttpCode, HttpStatus } from '@nestjs/common';
|
||||||
import { ApiTags, ApiOperation, ApiBearerAuth, ApiProperty } from '@nestjs/swagger';
|
import { ApiTags, ApiOperation, ApiBearerAuth, ApiProperty } from '@nestjs/swagger';
|
||||||
import { IsString, IsNotEmpty } from 'class-validator';
|
import { IsString, IsNotEmpty } from 'class-validator';
|
||||||
import { AuthService } from '../../application/services/auth.service';
|
import { AuthService } from '../../application/services/auth.service';
|
||||||
|
|
@ -29,6 +29,17 @@ export class AuthController {
|
||||||
return this.authService.login(dto.username, dto.password, req.ip, req.headers['user-agent']);
|
return this.authService.login(dto.username, dto.password, req.ip, req.headers['user-agent']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Get('profile')
|
||||||
|
@ApiBearerAuth()
|
||||||
|
@ApiOperation({ summary: '获取当前用户信息' })
|
||||||
|
async getProfile(@Req() req: any) {
|
||||||
|
return {
|
||||||
|
id: req.admin.id,
|
||||||
|
username: req.admin.username,
|
||||||
|
role: req.admin.role,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@Post('logout')
|
@Post('logout')
|
||||||
@ApiBearerAuth()
|
@ApiBearerAuth()
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue