diff options
author | zeripath <art27@cantab.net> | 2020-02-27 19:20:55 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-27 16:20:55 -0300 |
commit | 90919bb37e2bcc62440e393439825fe0e1e1f343 (patch) | |
tree | 1e89ce6ec5a3c90399a1621e6d11dae2417c11ef /models/repo_collaboration.go | |
parent | 858aebc2d8561803c4dc3f8a427ca82662ee96c7 (diff) | |
download | gitea-90919bb37e2bcc62440e393439825fe0e1e1f343.tar.gz gitea-90919bb37e2bcc62440e393439825fe0e1e1f343.zip |
Show Signer in commit lists and add basic trust (#10425)
* Show Signer in commit lists and add basic trust
Show the avatar of the signer in the commit list pages as we do not
enforce that the signer is an author or committer. This makes it
clearer who has signed the commit.
Also display commits signed by non-members differently from
members and in particular make it clear when a non-member signer
is different from the committer to help reduce the risk of
spoofing.
Signed-off-by: Andrew Thornton <art27@cantab.net>
* ensure orange text and background is available
Signed-off-by: Andrew Thornton <art27@cantab.net>
* Update gpg_key.go
* Update models/gpg_key.go
* Apply suggestions from code review
* Require team collaborators to have access to UnitTypeCode
* as per @6543
* fix position of sha as per @silverwind
* as per @guillep2k
Diffstat (limited to 'models/repo_collaboration.go')
-rw-r--r-- | models/repo_collaboration.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/models/repo_collaboration.go b/models/repo_collaboration.go index 8c6ef36230..85bc99f320 100644 --- a/models/repo_collaboration.go +++ b/models/repo_collaboration.go @@ -210,3 +210,23 @@ func (repo *Repository) getRepoTeams(e Engine) (teams []*Team, err error) { func (repo *Repository) GetRepoTeams() ([]*Team, error) { return repo.getRepoTeams(x) } + +// IsOwnerMemberCollaborator checks if a provided user is the owner, a collaborator or a member of a team in a repository +func (repo *Repository) IsOwnerMemberCollaborator(userID int64) (bool, error) { + if repo.OwnerID == userID { + return true, nil + } + teamMember, err := x.Join("INNER", "team_repo", "team_repo.team_id = team_user.team_id"). + Join("INNER", "team_unit", "team_unit.team_id = team_user.team_id"). + Where("team_repo.repo_id = ?", repo.ID). + And("team_unit.`type` = ?", UnitTypeCode). + And("team_user.uid = ?", userID).Table("team_user").Exist(&TeamUser{}) + if err != nil { + return false, err + } + if teamMember { + return true, nil + } + + return x.Get(&Collaboration{RepoID: repo.ID, UserID: userID}) +} |