diff --git a/Deploy/templates/registry/config.yml b/Deploy/templates/registry/config.yml index 999488a95..faabe10cd 100644 --- a/Deploy/templates/registry/config.yml +++ b/Deploy/templates/registry/config.yml @@ -30,6 +30,6 @@ notifications: - name: harbor disabled: false url: http://ui/service/notifications - timeout: 500ms + timeout: 3000ms threshold: 5 backoff: 1s diff --git a/api/replication_job.go b/api/replication_job.go index bc1fced44..95f795194 100644 --- a/api/replication_job.go +++ b/api/replication_job.go @@ -127,6 +127,10 @@ func (ra *RepJobAPI) Delete() { ra.CustomAbort(http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError)) } + if job == nil { + ra.CustomAbort(http.StatusNotFound, fmt.Sprintf("job %d not found", ra.jobID)) + } + if job.Status == models.JobPending || job.Status == models.JobRunning { ra.CustomAbort(http.StatusBadRequest, fmt.Sprintf("job is %s, can not be deleted", job.Status)) } diff --git a/api/repository.go b/api/repository.go index 84d4ac286..e14eda423 100644 --- a/api/repository.go +++ b/api/repository.go @@ -222,6 +222,10 @@ func (ra *RepositoryAPI) GetTags() { ra.CustomAbort(http.StatusInternalServerError, "") } + if project == nil { + ra.CustomAbort(http.StatusNotFound, fmt.Sprintf("project %s not found", projectName)) + } + if project.Public == 0 { userID := ra.ValidateUser() if !checkProjectPermission(userID, project.ProjectID) { diff --git a/controllers/base.go b/controllers/base.go index bd9a23bf7..bd3171926 100644 --- a/controllers/base.go +++ b/controllers/base.go @@ -107,6 +107,12 @@ func (b *BaseController) Prepare() { if _, err := os.Stat(filepath.Join("static", "resources", "js", "harbor.app.min.js")); os.IsNotExist(err) { b.UseCompressedJS = false } + + selfRegistration := strings.ToLower(os.Getenv("SELF_REGISTRATION")) + if selfRegistration == "on" { + b.SelfRegistration = true + } + b.Data["SelfRegistration"] = b.SelfRegistration } // Forward to setup layout and template for content for a page. diff --git a/controllers/signup.go b/controllers/signup.go index 9d46a368b..6ed75b01b 100644 --- a/controllers/signup.go +++ b/controllers/signup.go @@ -11,7 +11,7 @@ type SignUpController struct { // Get renders sign up page func (suc *SignUpController) Get() { - if suc.AuthMode != "db_auth" { + if suc.AuthMode != "db_auth" || !suc.SelfRegistration { suc.CustomAbort(http.StatusUnauthorized, "Status unauthorized.") } suc.Data["AddNew"] = false diff --git a/dao/accesslog.go b/dao/accesslog.go index b76a40072..7d268f10f 100644 --- a/dao/accesslog.go +++ b/dao/accesslog.go @@ -195,7 +195,7 @@ func GetTopRepos(countNum int) ([]models.TopRepo, error) { for i := 0; i < len(list); i++ { for _, v := range usrnameList { if v.RepoName == list[i].RepoName { - list[i].Creator = v.Creator + // list[i].Creator = v.Creator break } } diff --git a/dao/dao_test.go b/dao/dao_test.go index 52ea37a27..5dccc51ea 100644 --- a/dao/dao_test.go +++ b/dao/dao_test.go @@ -770,9 +770,11 @@ func TestGetTopRepos(t *testing.T) { if topRepos[0].AccessCount != 1 { t.Errorf("error occured in get top reop's access count, expected: %v, actual: %v", 1, topRepos[0].AccessCount) } - if topRepos[0].Creator != currentUser.Username { - t.Errorf("error occured in get top reop's creator, expected: %v, actual: %v", currentUser.Username, topRepos[0].Creator) - } + /* + if topRepos[0].Creator != currentUser.Username { + t.Errorf("error occured in get top reop's creator, expected: %v, actual: %v", currentUser.Username, topRepos[0].Creator) + } + */ err = ToggleProjectPublicity(currentProject.ProjectID, publicityOff) if err != nil { t.Errorf("Error occurred in ToggleProjectPublicity: %v", err) diff --git a/models/toprepo.go b/models/toprepo.go index 6ccb46227..b977e4c18 100644 --- a/models/toprepo.go +++ b/models/toprepo.go @@ -19,5 +19,5 @@ package models type TopRepo struct { RepoName string `json:"name"` AccessCount int64 `json:"count"` - Creator string `json:"creator"` + // Creator string `json:"creator"` } diff --git a/static/resources/js/components/top-repository/top-repository.directive.html b/static/resources/js/components/top-repository/top-repository.directive.html index c45a7adfa..a44c1dc93 100644 --- a/static/resources/js/components/top-repository/top-repository.directive.html +++ b/static/resources/js/components/top-repository/top-repository.directive.html @@ -18,8 +18,7 @@ - - +
// 'repository_name' | tr //// 'count' | tr //// 'creator' | tr //// 'count' | tr //
@@ -30,7 +29,7 @@

// 'no_top_repositories' | tr //

- //t.name////t.count////t.creator === '' ? '-' : t.creator // + //t.name////t.count// diff --git a/views/sign-in.htm b/views/sign-in.htm index a4bd94975..3d0e551a0 100644 --- a/views/sign-in.htm +++ b/views/sign-in.htm @@ -46,7 +46,7 @@
- {{ if eq .AuthMode "db_auth" }} + {{ if and (eq .AuthMode "db_auth") (eq .SelfRegistration true) }} {{ end }}