mirror of
https://github.com/go-gitea/gitea.git
synced 2025-06-22 05:58:02 +02:00
Restrict permission check on repositories and fix some problems (#5314)
* fix units permission problems * fix some bugs and merge LoadUnits to repoAssignment * refactor permission struct and add some copyright heads * remove unused codes * fix routes units check * improve permission check * add unit tests for permission * fix typo * fix tests * fix some routes * fix api permission check * improve permission check * fix some permission check * fix tests * fix tests * improve some permission check * fix some permission check * refactor AccessLevel * fix bug * fix tests * fix tests * fix tests * fix AccessLevel * rename CanAccess * fix tests * fix comment * fix bug * add missing unit for test repos * fix bug * rename some functions * fix routes check
This commit is contained in:
@ -4,7 +4,7 @@
|
||||
<div class="ui container">
|
||||
<div class="navbar">
|
||||
{{template "repo/issue/navbar" .}}
|
||||
{{if .IsRepositoryWriter}}
|
||||
{{if or .CanWriteIssues .CanWritePulls}}
|
||||
<div class="ui right">
|
||||
<div class="ui green new-label button">{{.i18n.Tr "repo.issues.new_label"}}</div>
|
||||
</div>
|
||||
@ -57,7 +57,7 @@
|
||||
{{template "base/alert" .}}
|
||||
<div class="ui black label">{{.i18n.Tr "repo.issues.label_count" .NumLabels}}</div>
|
||||
<div class="label list">
|
||||
{{if and $.IsRepositoryWriter (eq .NumLabels 0)}}
|
||||
{{if and (or $.CanWriteIssues $.CanWritePulls) (eq .NumLabels 0)}}
|
||||
<div class="ui centered grid">
|
||||
<div class="twelve wide column eight wide computer column">
|
||||
<div class="ui attached left aligned segment">
|
||||
@ -105,7 +105,7 @@
|
||||
<a class="ui right open-issues" href="{{$.RepoLink}}/issues?labels={{.ID}}"><i class="octicon octicon-issue-opened"></i> {{$.i18n.Tr "repo.issues.label_open_issues" .NumOpenIssues}}</a>
|
||||
</div>
|
||||
<div class="three wide column">
|
||||
{{if $.IsRepositoryWriter}}
|
||||
{{if or $.CanWriteIssues $.CanWritePulls}}
|
||||
<a class="ui right delete-button" href="#" data-url="{{$.RepoLink}}/labels/delete" data-id="{{.ID}}"><i class="octicon octicon-trashcan"></i> {{$.i18n.Tr "repo.issues.label_delete"}}</a>
|
||||
<a class="ui right edit-label-button" href="#" data-id="{{.ID}}" data-title="{{.Name}}" data-description="{{.Description}}" data-color={{.Color}}><i class="octicon octicon-pencil"></i> {{$.i18n.Tr "repo.issues.label_edit"}}</a>
|
||||
{{end}}
|
||||
@ -117,7 +117,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{if .IsRepositoryWriter}}
|
||||
{{if or $.CanWriteIssues $.CanWritePulls}}
|
||||
<div class="ui small basic delete modal">
|
||||
<div class="ui icon header">
|
||||
<i class="trash icon"></i>
|
||||
|
@ -4,7 +4,7 @@
|
||||
<div class="ui container">
|
||||
<div class="navbar">
|
||||
{{template "repo/issue/navbar" .}}
|
||||
{{if and .IsRepositoryWriter .PageIsEditMilestone}}
|
||||
{{if and (or .CanWriteIssues .CanWritePulls) .PageIsEditMilestone}}
|
||||
<div class="ui right floated secondary menu">
|
||||
<a class="ui green button" href="{{$.RepoLink}}/milestones/new">{{.i18n.Tr "repo.milestones.new"}}</a>
|
||||
</div>
|
||||
|
@ -4,7 +4,7 @@
|
||||
<div class="ui container">
|
||||
<div class="navbar">
|
||||
{{template "repo/issue/navbar" .}}
|
||||
{{if .IsRepositoryWriter}}
|
||||
{{if or .CanWriteIssues .CanWritePulls}}
|
||||
<div class="ui right">
|
||||
<a class="ui green button" href="{{$.Link}}/new">{{.i18n.Tr "repo.milestones.new"}}</a>
|
||||
</div>
|
||||
@ -67,7 +67,7 @@
|
||||
{{if .TotalTrackedTime}}<i class="octicon octicon-clock"></i> {{.TotalTrackedTime|Sec2Time}}{{end}}
|
||||
</span>
|
||||
</div>
|
||||
{{if $.IsRepositoryWriter}}
|
||||
{{if or $.CanWriteIssues $.CanWritePulls}}
|
||||
<div class="ui right operate">
|
||||
<a href="{{$.Link}}/{{.ID}}/edit" data-id={{.ID}} data-title={{.Name}}><i class="octicon octicon-pencil"></i> {{$.i18n.Tr "repo.issues.label_edit"}}</a>
|
||||
{{if .IsClosed}}
|
||||
@ -111,7 +111,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{if .IsRepositoryWriter}}
|
||||
{{if or .CanWriteIssues .CanWritePulls}}
|
||||
<div class="ui small basic delete modal">
|
||||
<div class="ui icon header">
|
||||
<i class="trash icon"></i>
|
||||
|
@ -20,7 +20,7 @@
|
||||
<span class="text grey"><a {{if gt .Issue.Poster.ID 0}}href="{{.Issue.Poster.HomeLink}}"{{end}}>{{.Issue.Poster.Name}}</a> {{.i18n.Tr "repo.issues.commented_at" .Issue.HashTag $createdStr | Safe}}</span>
|
||||
<div class="ui right actions">
|
||||
{{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/issues/%d/reactions" $.RepoLink .Issue.Index) }}
|
||||
{{if .IsIssueOwner}}
|
||||
{{if or .IsIssueWriter .IsIssuePoster}}
|
||||
<div class="item action">
|
||||
<a class="edit-content" href="#"><i class="octicon octicon-pencil"></i></a>
|
||||
</div>
|
||||
@ -79,7 +79,7 @@
|
||||
{{.CsrfTokenHtml}}
|
||||
<input id="status" name="status" type="hidden">
|
||||
<div class="text right">
|
||||
{{if and .IsIssueOwner (not .DisableStatusChange)}}
|
||||
{{if and (or .IsIssueWriter .IsIssuePoster) (not .DisableStatusChange)}}
|
||||
{{if .Issue.IsClosed}}
|
||||
<div id="status-button" class="ui green basic button" tabindex="6" data-status="{{.i18n.Tr "repo.issues.reopen_issue"}}" data-status-and-comment="{{.i18n.Tr "repo.issues.reopen_comment_issue"}}" data-status-val="reopen">
|
||||
{{.i18n.Tr "repo.issues.reopen_issue"}}
|
||||
|
@ -23,7 +23,7 @@
|
||||
</div>
|
||||
{{end}}
|
||||
{{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) }}
|
||||
{{if or $.IsRepositoryAdmin (eq .Poster.ID $.SignedUserID)}}
|
||||
{{if or $.Permission.IsAdmin (eq .Poster.ID $.SignedUserID)}}
|
||||
<div class="item action">
|
||||
<a class="edit-content" href="#"><i class="octicon octicon-pencil"></i></a>
|
||||
<a class="delete-comment" href="#" data-comment-id={{.HashTag}} data-url="{{$.RepoLink}}/comments/{{.ID}}/delete" data-locale="{{$.i18n.Tr "repo.issues.delete_comment_confirm"}}"><i class="octicon octicon-x"></i></a>
|
||||
|
@ -2,7 +2,7 @@
|
||||
<div class="ui segment metas">
|
||||
{{template "repo/issue/branch_selector_field" .}}
|
||||
|
||||
<div class="ui {{if not .IsRepositoryWriter}}disabled{{end}} floating jump select-label dropdown">
|
||||
<div class="ui {{if not .IsIssueWriter}}disabled{{end}} floating jump select-label dropdown">
|
||||
<span class="text">
|
||||
<strong>{{.i18n.Tr "repo.issues.new.labels"}}</strong>
|
||||
<span class="octicon octicon-gear"></span>
|
||||
@ -27,7 +27,7 @@
|
||||
|
||||
<div class="ui divider"></div>
|
||||
|
||||
<div class="ui {{if not .IsRepositoryWriter}}disabled{{end}} floating jump select-milestone dropdown">
|
||||
<div class="ui {{if not .IsIssueWriter}}disabled{{end}} floating jump select-milestone dropdown">
|
||||
<span class="text">
|
||||
<strong>{{.i18n.Tr "repo.issues.new.milestone"}}</strong>
|
||||
<span class="octicon octicon-gear"></span>
|
||||
@ -68,7 +68,7 @@
|
||||
<div class="ui divider"></div>
|
||||
|
||||
<input id="assignee_id" name="assignee_id" type="hidden" value="{{.assignee_id}}">
|
||||
<div class="ui {{if not .IsRepositoryWriter}}disabled{{end}} floating jump select-assignees-modify dropdown">
|
||||
<div class="ui {{if not .IsIssueWriter}}disabled{{end}} floating jump select-assignees-modify dropdown">
|
||||
<span class="text">
|
||||
<strong>{{.i18n.Tr "repo.issues.new.assignees"}}</strong>
|
||||
<span class="octicon octicon-gear"></span>
|
||||
@ -223,7 +223,7 @@
|
||||
{{if .Issue.IsOverdue}}
|
||||
<span style="color: red;">{{.i18n.Tr "repo.issues.due_date_overdue"}}</span>
|
||||
{{end}}
|
||||
{{if and .IsSigned .IsRepositoryWriter}}
|
||||
{{if .IsIssueWriter}}
|
||||
<br/>
|
||||
<a style="cursor:pointer;" onclick="toggleDeadlineForm();"><i class="edit icon"></i>{{$.i18n.Tr "repo.issues.due_date_form_edit"}}</a> -
|
||||
<a style="cursor:pointer;" onclick="updateDeadline('');"><i class="remove icon"></i>{{$.i18n.Tr "repo.issues.due_date_form_remove"}}</a>
|
||||
@ -233,7 +233,7 @@
|
||||
<p><i>{{.i18n.Tr "repo.issues.due_date_not_set"}}</i></p>
|
||||
{{end}}
|
||||
|
||||
{{if and .IsSigned .IsRepositoryWriter}}
|
||||
{{if .IsIssueWriter}}
|
||||
<div {{if ne .Issue.DeadlineUnix 0}} style="display: none;"{{end}} id="deadlineForm">
|
||||
<form class="ui fluid action input" action="{{AppSubUrl}}/api/v1/repos/{{.Repository.Owner.Name}}/{{.Repository.Name}}/issues/{{.Issue.Index}}" method="post" id="update-issue-deadline-form" onsubmit="setDeadline();return false;">
|
||||
{{$.CsrfTokenHtml}}
|
||||
|
@ -6,7 +6,7 @@
|
||||
<input value="{{.Issue.Title}}">
|
||||
</div>
|
||||
</h1>
|
||||
{{if .IsIssueOwner}}
|
||||
{{if or .IsIssueWriter .IsIssuePoster}}
|
||||
<div class="four wide column">
|
||||
<div class="edit-zone text right">
|
||||
<div id="edit-title" class="ui basic green not-in-edit button">{{.i18n.Tr "repo.issues.edit"}}</div>
|
||||
|
Reference in New Issue
Block a user