-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
User shouldn't be able to approve or reject his/her own PR #4729
Changes from 2 commits
8951891
4bb258c
27e5587
7e7454c
55edbc3
9f86967
3b019d8
2a4a5fc
654daad
f39a834
67989c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,6 +108,30 @@ func SubmitReview(ctx *context.Context, form auth.SubmitReviewForm) { | |
return | ||
} | ||
|
||
switch reviewType { | ||
case models.ReviewTypeUnknown: | ||
ctx.ServerError("GetCurrentReview", fmt.Errorf("unknown ReviewType: %s", form.Type)) | ||
return | ||
|
||
// can not approve/reject your own PR | ||
case models.ReviewTypeApprove, models.ReviewTypeReject: | ||
|
||
if issue.Poster.ID == ctx.User.ID { | ||
|
||
var translated string | ||
|
||
if reviewType == models.ReviewTypeApprove { | ||
translated = ctx.Tr("repo.issues.review.self.approval") | ||
} else { | ||
translated = ctx.Tr("repo.issues.review.self.rejection") | ||
} | ||
|
||
ctx.Flash.Error(translated) | ||
ctx.Redirect(fmt.Sprintf("%s/pulls/%d", ctx.Repo.RepoLink, issue.Index)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please redirect to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add alert to to files template There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed @JonasFranzDEV and @lafriks |
||
return | ||
} | ||
} | ||
|
||
if form.HasEmptyContent() { | ||
ctx.Flash.Error(ctx.Tr("repo.issues.review.content.empty")) | ||
ctx.Redirect(fmt.Sprintf("%s/pulls/%d", ctx.Repo.RepoLink, issue.Index)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this just be
ctx.IsSigned && issue.IsPoster(ctx.User.ID)