@@ -61,6 +61,12 @@ func ServNoCommand(ctx *macaron.Context) {
61
61
})
62
62
return
63
63
}
64
+ if ! user .IsActive || user .ProhibitLogin {
65
+ ctx .JSON (http .StatusForbidden , map [string ]interface {}{
66
+ "err" : "Your account is disabled." ,
67
+ })
68
+ return
69
+ }
64
70
results .Owner = user
65
71
}
66
72
ctx .JSON (http .StatusOK , & results )
@@ -98,9 +104,28 @@ func ServCommand(ctx *macaron.Context) {
98
104
results .RepoName = repoName [:len (repoName )- 5 ]
99
105
}
100
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
+
101
126
// Now get the Repository and set the results section
102
127
repoExist := true
103
- repo , err := models .GetRepositoryByOwnerAndName ( results . OwnerName , results .RepoName )
128
+ repo , err := models .GetRepositoryByName ( owner . ID , results .RepoName )
104
129
if err != nil {
105
130
if models .IsErrRepoNotExist (err ) {
106
131
repoExist = false
@@ -127,6 +152,7 @@ func ServCommand(ctx *macaron.Context) {
127
152
}
128
153
129
154
if repoExist {
155
+ repo .Owner = owner
130
156
repo .OwnerName = ownerName
131
157
results .RepoID = repo .ID
132
158
@@ -217,15 +243,6 @@ func ServCommand(ctx *macaron.Context) {
217
243
// so for now use the owner of the repository
218
244
results .UserName = results .OwnerName
219
245
results .UserID = repo .OwnerID
220
- if err = repo .GetOwner (); err != nil {
221
- log .Error ("Unable to get owner for repo %-v. Error: %v" , repo , err )
222
- ctx .JSON (http .StatusInternalServerError , map [string ]interface {}{
223
- "results" : results ,
224
- "type" : "InternalServerError" ,
225
- "err" : fmt .Sprintf ("Unable to get owner for repo: %s/%s." , results .OwnerName , results .RepoName ),
226
- })
227
- return
228
- }
229
246
if ! repo .Owner .KeepEmailPrivate {
230
247
results .UserEmail = repo .Owner .Email
231
248
}
@@ -250,6 +267,14 @@ func ServCommand(ctx *macaron.Context) {
250
267
})
251
268
return
252
269
}
270
+
271
+ if ! user .IsActive || user .ProhibitLogin {
272
+ ctx .JSON (http .StatusForbidden , map [string ]interface {}{
273
+ "err" : "Your account is disabled." ,
274
+ })
275
+ return
276
+ }
277
+
253
278
results .UserName = user .Name
254
279
if ! user .KeepEmailPrivate {
255
280
results .UserEmail = user .Email
0 commit comments