Skip to content
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

bug:fix add assignees permission bug on New PR from forked repo #10848

Closed
wants to merge 1 commit into from

Conversation

a1012112796
Copy link
Member

@a1012112796 a1012112796 commented Mar 27, 2020

In gitea now seting, only users have write permission can add Assignees, but if a user who don't have write permission also can add Assignees when they creat a Pull Request from a forked repo ,
Because It haven't check the permission, so it's a bug . This PR should fix this bug by add a check for it.

two other small changes:

before change:

make PR frm a forked repo:
jta

after change:
fixed

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 27, 2020
Comment on lines -132 to -153

<!-- input id="assignee_ids" name="assignee_ids" type="hidden" value="{{.assignee_id}}">
<div class="ui {{if not .Assignees}}disabled{{end}} floating jump select-assignee dropdown">
<span class="text">
<strong>{{.i18n.Tr "repo.issues.new.assignees"}}</strong>
<span class="octicon octicon-gear"></span>
</span>
<div class="filter menu">
<div class="no-select item">{{.i18n.Tr "repo.issues.new.clear_assignees"}}</div>
{{range .Assignees}}
<div class="item" data-id="{{.ID}}" data-href="{{$.RepoLink}}/issues?assignee={{.ID}}" data-avatar="{{.RelAvatarLink}}"><img src="{{.RelAvatarLink}}"> {{.Name}}</div>
{{end}}
</div>
</div>
<div class="ui select-assignee list">
<span class="no-select item {{if .Assignee}}hide{{end}}">{{.i18n.Tr "repo.issues.new.no_assignees"}}</span>
<div class="selected">
{{if .Assignee}}
<a class="item" href="{{.RepoLink}}/issues?assignee={{.Assignee.ID}}"><img class="ui avatar image" src="{{.Assignee.RelAvatarLink}}"> {{.Assignee.Name}}</a>
{{end}}
</div>
</div>-->
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, I don't think these comments are usefull, so I suggest to remove them, If it have some special reason that should be kept. please tell me, I will recover them. thanks

@lafriks
Copy link
Member

lafriks commented Mar 27, 2020

I don't think user with read permissions should be able to set assignee

@a1012112796
Copy link
Member Author

Hello, so, I add an extern check for it on new pull request page , Is something wrong about it?
@lafriks

In gitea now seting, only users have write permission can add Assignees, but if a
user who don't have write permission also can add Assignees when they creat a Pull
Request from a forked repo ,Because It haven't check the permission, so it's a bug.
This PR should fix this bug by add a check for write permission.

two other small changes:

* hide gear on new PR page when it's not necessary like go-gitea#10750,
* remove some unusefull comments.

Signed-off-by: a1012112796 <[email protected]>
@a1012112796 a1012112796 changed the title bug: fix add Assignees permission bug on New Pull Request Page from forked repo bug:fix add assignees permission bug on New PR from forked repo Mar 27, 2020
@codecov-io
Copy link

Codecov Report

Merging #10848 into master will decrease coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10848      +/-   ##
==========================================
- Coverage   43.52%   43.49%   -0.03%     
==========================================
  Files         590      592       +2     
  Lines       82809    82907      +98     
==========================================
+ Hits        36040    36063      +23     
- Misses      42290    42364      +74     
- Partials     4479     4480       +1     
Impacted Files Coverage Δ
routers/repo/compare.go 40.70% <100.00%> (+0.26%) ⬆️
routers/user/avatar.go 23.25% <0.00%> (-20.23%) ⬇️
modules/base/tool.go 59.09% <0.00%> (-5.93%) ⬇️
services/pull/check.go 50.00% <0.00%> (-3.05%) ⬇️
modules/git/command.go 86.95% <0.00%> (-2.61%) ⬇️
modules/queue/workerpool.go 56.93% <0.00%> (-1.07%) ⬇️
modules/log/event.go 64.61% <0.00%> (-1.03%) ⬇️
models/notification.go 63.88% <0.00%> (-0.84%) ⬇️
modules/repository/commits.go 82.85% <0.00%> (ø)
models/migrations/migrations.go 4.16% <0.00%> (ø)
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a3f9094...e7b55b4. Read the comment docs.

@mrsdizzie
Copy link
Member

I think having a gear you can't click is a bug but I think it is better to do what Github does and show some text like 'nothing to show' or 'no labels defined' etc... if there are no labels/milestones. Removing the gear creates the impression that you aren't allowed to add them and is the same interface for users who don't have permission to add them.

That could be for another PR if this one wants to just fix the write issue and remove the comment

@a1012112796
Copy link
Member Author

I think having a gear you can't click is a bug but I think it is better to do what Github does and show some text like 'nothing to show' or 'no labels defined' etc... if there are no labels/milestones. Removing the gear creates the impression that you aren't allowed to add them and is the same interface for users who don't have permission to add them.

That could be for another PR if this one wants to just fix the write issue and remove the comment

I'm sorry , but maybe you missunderstand me , the bug is reader of a repo should not have permission to add assignees, but they can do it on New PR page now. the hide gear and delet
are bounded small change. but one thing you are right , it's on New PR page we have make no
distinction between having no permissions and having no options available for Labels, assignees, and Milestone, maybe It's necessary to make more check, so close this PR now. thanks for your suggestions.

@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants