@@ -104,9 +104,28 @@ func ServCommand(ctx *macaron.Context) {
104
104
results .RepoName = repoName [:len (repoName )- 5 ]
105
105
}
106
106
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
+
107
126
// Now get the Repository and set the results section
108
127
repoExist := true
109
- repo , err := models .GetRepositoryByOwnerAndName ( results . OwnerName , results .RepoName )
128
+ repo , err := models .GetRepositoryByName ( owner . ID , results .RepoName )
110
129
if err != nil {
111
130
if models .IsErrRepoNotExist (err ) {
112
131
repoExist = false
@@ -133,6 +152,7 @@ func ServCommand(ctx *macaron.Context) {
133
152
}
134
153
135
154
if repoExist {
155
+ repo .Owner = owner
136
156
repo .OwnerName = ownerName
137
157
results .RepoID = repo .ID
138
158
@@ -223,15 +243,6 @@ func ServCommand(ctx *macaron.Context) {
223
243
// so for now use the owner of the repository
224
244
results .UserName = results .OwnerName
225
245
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
- }
235
246
if ! repo .Owner .KeepEmailPrivate {
236
247
results .UserEmail = repo .Owner .Email
237
248
}
@@ -256,6 +267,14 @@ func ServCommand(ctx *macaron.Context) {
256
267
})
257
268
return
258
269
}
270
+
271
+ if ! user .IsActive {
272
+ ctx .JSON (http .StatusForbidden , map [string ]interface {}{
273
+ "err" : "Your account is disabled." ,
274
+ })
275
+ return
276
+ }
277
+
259
278
results .UserName = user .Name
260
279
if ! user .KeepEmailPrivate {
261
280
results .UserEmail = user .Email
0 commit comments