feat: 后端调整登陆逻辑

This commit is contained in:
2025-12-16 22:48:51 +08:00
parent b235ca8a6e
commit 70517058ae
13 changed files with 305 additions and 194 deletions

View File

@@ -22,7 +22,7 @@ export class BlogController {
constructor(
private readonly blogService: BlogService,
private readonly userService: UserService,
) {}
) { }
@Get()
getBlogs() {
@@ -100,7 +100,7 @@ export class BlogController {
throw new BadRequestException('作者关闭了该文章的评论功能');
}
const user = userId ? await this.userService.findById(userId) : null;
const user = userId ? await this.userService.findOne({ userId }) : null;
const ip = req.headers['x-forwarded-for'] || req.ip;
// 获取IP归属地