Skip to content

Commit 5d4c66d

Browse files
committed
fix: 修复匿名用户点赞评论无权限问题
1 parent 3bbd50c commit 5d4c66d

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/main/kotlin/plus/maa/backend/config/security/SecurityConfig.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class SecurityConfig(
107107
"/copilot/get/**",
108108
"/copilot/rating",
109109
"/comments/query",
110-
"/file/upload",
110+
"/comments/rating",
111111
"/copilot/ban",
112112
"/webhook/**",
113113
)

src/main/kotlin/plus/maa/backend/controller/CommentsAreaController.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class CommentsAreaController(
6363
@RequireJwt
6464
@PostMapping("/rating")
6565
fun ratesComments(@RequestBody commentsRatingDTO: @Valid CommentsRatingDTO): MaaResult<String> {
66-
commentsAreaService.rates(authHelper.userId, commentsRatingDTO)
66+
commentsAreaService.rates(authHelper.obtainUserIdOrIpAddress(), commentsRatingDTO)
6767
return success("成功")
6868
}
6969

src/main/kotlin/plus/maa/backend/service/CommentsAreaService.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,13 @@ class CommentsAreaService(
129129
* @param userId 登录用户 id
130130
* @param commentsRatingDTO CommentsRatingDTO
131131
*/
132-
fun rates(userId: Long, commentsRatingDTO: CommentsRatingDTO) {
132+
fun rates(userId: String, commentsRatingDTO: CommentsRatingDTO) {
133133
val commentId = commentsRatingDTO.commentId
134134
val commentsArea = requireCommentsAreaById(commentId)
135135

136136
val ratingChange = ratingService.rateComment(
137137
commentId,
138-
userId.toString(),
138+
userId,
139139
RatingType.fromRatingType(commentsRatingDTO.rating),
140140
)
141141
// 更新评分后更新评论的点赞数

0 commit comments

Comments
 (0)