@@ -104,9 +104,28 @@ func ServCommand(ctx *macaron.Context) {
104104 results .RepoName = repoName [:len (repoName )- 5 ]
105105 }
106106
107+ owner , err := models .GetUserByName (results .OwnerName )
108+ if err != nil {
109+ log .Error ("Unable to get repository owner: %s/%s Error: %v" , results .OwnerName , results .RepoName , err )
110+ ctx .JSON (http .StatusInternalServerError , map [string ]interface {}{
111+ "results" : results ,
112+ "type" : "InternalServerError" ,
113+ "err" : fmt .Sprintf ("Unable to get repository owner: %s/%s %v" , results .OwnerName , results .RepoName , err ),
114+ })
115+ return
116+ }
117+ if ! owner .IsActive {
118+ ctx .JSON (http .StatusForbidden , map [string ]interface {}{
119+ "results" : results ,
120+ "type" : "ForbiddenError" ,
121+ "err" : "Repository cannot be accessed, you could retry it later" ,
122+ })
123+ return
124+ }
125+
107126 // Now get the Repository and set the results section
108127 repoExist := true
109- repo , err := models .GetRepositoryByOwnerAndName ( results . OwnerName , results .RepoName )
128+ repo , err := models .GetRepositoryByName ( owner . ID , results .RepoName )
110129 if err != nil {
111130 if models .IsErrRepoNotExist (err ) {
112131 repoExist = false
@@ -133,6 +152,7 @@ func ServCommand(ctx *macaron.Context) {
133152 }
134153
135154 if repoExist {
155+ repo .Owner = owner
136156 repo .OwnerName = ownerName
137157 results .RepoID = repo .ID
138158
@@ -223,15 +243,6 @@ func ServCommand(ctx *macaron.Context) {
223243 // so for now use the owner of the repository
224244 results .UserName = results .OwnerName
225245 results .UserID = repo .OwnerID
226- if err = repo .GetOwner (); err != nil {
227- log .Error ("Unable to get owner for repo %-v. Error: %v" , repo , err )
228- ctx .JSON (http .StatusInternalServerError , map [string ]interface {}{
229- "results" : results ,
230- "type" : "InternalServerError" ,
231- "err" : fmt .Sprintf ("Unable to get owner for repo: %s/%s." , results .OwnerName , results .RepoName ),
232- })
233- return
234- }
235246 if ! repo .Owner .KeepEmailPrivate {
236247 results .UserEmail = repo .Owner .Email
237248 }
@@ -256,6 +267,14 @@ func ServCommand(ctx *macaron.Context) {
256267 })
257268 return
258269 }
270+
271+ if ! user .IsActive {
272+ ctx .JSON (http .StatusForbidden , map [string ]interface {}{
273+ "err" : "Your account is disabled." ,
274+ })
275+ return
276+ }
277+
259278 results .UserName = user .Name
260279 if ! user .KeepEmailPrivate {
261280 results .UserEmail = user .Email
0 commit comments