@ -61,6 +61,12 @@ func ServNoCommand(ctx *macaron.Context) {
} )
return
}
if ! user . IsActive || user . ProhibitLogin {
ctx . JSON ( http . StatusForbidden , map [ string ] interface { } {
"err" : "Your account is disabled." ,
} )
return
}
results . Owner = user
}
ctx . JSON ( http . StatusOK , & results )
@ -98,9 +104,28 @@ func ServCommand(ctx *macaron.Context) {
results . RepoName = repoName [ : len ( repoName ) - 5 ]
}
owner , err := models . GetUserByName ( results . OwnerName )
if err != nil {
log . Error ( "Unable to get repository owner: %s/%s Error: %v" , results . OwnerName , results . RepoName , err )
ctx . JSON ( http . StatusInternalServerError , map [ string ] interface { } {
"results" : results ,
"type" : "InternalServerError" ,
"err" : fmt . Sprintf ( "Unable to get repository owner: %s/%s %v" , results . OwnerName , results . RepoName , err ) ,
} )
return
}
if ! owner . IsActive {
ctx . JSON ( http . StatusForbidden , map [ string ] interface { } {
"results" : results ,
"type" : "ForbiddenError" ,
"err" : "Repository cannot be accessed, you could retry it later" ,
} )
return
}
// Now get the Repository and set the results section
repoExist := true
repo , err := models . GetRepositoryByOwnerAndName ( results . OwnerName , results . RepoName )
repo , err := models . GetRepositoryByName ( owner . ID , results . RepoName )
if err != nil {
if models . IsErrRepoNotExist ( err ) {
repoExist = false
@ -127,6 +152,7 @@ func ServCommand(ctx *macaron.Context) {
}
if repoExist {
repo . Owner = owner
repo . OwnerName = ownerName
results . RepoID = repo . ID
@ -238,6 +264,14 @@ func ServCommand(ctx *macaron.Context) {
} )
return
}
if ! user . IsActive || user . ProhibitLogin {
ctx . JSON ( http . StatusForbidden , map [ string ] interface { } {
"err" : "Your account is disabled." ,
} )
return
}
results . UserName = user . Name
}