fix(rank): Incorrect permission verification

user can update answer that put by himself.
admin can vote up anyway.
This commit is contained in:
LinkinStar 2022-12-06 14:45:29 +08:00
parent 8c4dc92f58
commit a6630670be
2 changed files with 5 additions and 1 deletions

View File

@ -161,7 +161,7 @@ func (ac *AnswerController) Update(ctx *gin.Context) {
canList, err := ac.rankService.CheckOperationPermissions(ctx, req.UserID, []string{
rank.AnswerEditRank,
rank.AnswerEditWithoutReviewRank,
}, "")
}, req.ID)
if err != nil {
handler.HandleResponse(ctx, err, nil)
return

View File

@ -170,6 +170,10 @@ func (rs *RankService) CheckVotePermission(ctx context.Context, userID, objectID
if !exist {
return can, nil
}
// administrator have all permissions
if userInfo.IsAdmin {
return true, nil
}
objectInfo, err := rs.objectInfoService.GetInfo(ctx, objectID)
if err != nil {