@@ -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
@@ -238,6 +264,14 @@ func ServCommand(ctx *macaron.Context) {
238
264
})
239
265
return
240
266
}
267
+
268
+ if ! user .IsActive || user .ProhibitLogin {
269
+ ctx .JSON (http .StatusForbidden , map [string ]interface {}{
270
+ "err" : "Your account is disabled." ,
271
+ })
272
+ return
273
+ }
274
+
241
275
results .UserName = user .Name
242
276
}
243
277
0 commit comments