Browse Source

Prevent NPE when checking repo units if the user is nil (#19625) (#19630)

Backport #19625

CheckRepoUnitUser should tolerate nil users.

Fix #19613

Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
tags/v1.16.8
zeripath 3 years ago committed by GitHub
parent
commit
18dd49a4ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      models/repo.go

2
models/repo.go

@ -132,7 +132,7 @@ func CheckRepoUnitUser(repo *repo_model.Repository, user *user_model.User, unitT
}
func checkRepoUnitUser(ctx context.Context, repo *repo_model.Repository, user *user_model.User, unitType unit.Type) bool {
if user.IsAdmin {
if user != nil && user.IsAdmin {
return true
}
perm, err := getUserRepoPermission(ctx, repo, user)

Loading…
Cancel
Save