aboutsummaryrefslogtreecommitdiff
path: root/routers/repo/http.go
diff options
context:
space:
mode:
authorDon Bowman <don.waterloo@gmail.com>2015-08-12 21:10:00 +0000
committerDon Bowman <don.waterloo@gmail.com>2015-08-12 21:10:00 +0000
commit1cb46ede1acf4f8527e64fcae7e92672cad764b2 (patch)
treefabb54ee5f040be2a4ee5c95f87cb3e9fbf7bdea /routers/repo/http.go
parent9e6bd31d76aa6d6495a2144466af78773f34d07c (diff)
parentaede5cdb04fdbf74d9c602062fdece9f408e90f4 (diff)
Merge branch 'master' of https://github.com/gogits/gogs
Conflicts: routers/repo/download.go
Diffstat (limited to 'routers/repo/http.go')
-rw-r--r--routers/repo/http.go23
1 files changed, 13 insertions, 10 deletions
diff --git a/routers/repo/http.go b/routers/repo/http.go
index 9165128a..45b0ec59 100644
--- a/routers/repo/http.go
+++ b/routers/repo/http.go
@@ -55,7 +55,7 @@ func Http(ctx *middleware.Context) {
repoUser, err := models.GetUserByName(username)
if err != nil {
- if err == models.ErrUserNotExist {
+ if models.IsErrUserNotExist(err) {
ctx.Handle(404, "GetUserByName", nil)
} else {
ctx.Handle(500, "GetUserByName", err)
@@ -96,18 +96,18 @@ func Http(ctx *middleware.Context) {
// FIXME: middlewares/context.go did basic auth check already,
// maybe could use that one.
if len(auths) != 2 || auths[0] != "Basic" {
- ctx.Handle(401, "no basic auth and digit auth", nil)
+ ctx.HandleText(401, "no basic auth and digit auth")
return
}
authUsername, authPasswd, err = base.BasicAuthDecode(auths[1])
if err != nil {
- ctx.Handle(401, "no basic auth and digit auth", nil)
+ ctx.HandleText(401, "no basic auth and digit auth")
return
}
authUser, err = models.UserSignIn(authUsername, authPasswd)
if err != nil {
- if err != models.ErrUserNotExist {
+ if !models.IsErrUserNotExist(err) {
ctx.Handle(500, "UserSignIn error: %v", err)
return
}
@@ -116,7 +116,7 @@ func Http(ctx *middleware.Context) {
token, err := models.GetAccessTokenBySha(authUsername)
if err != nil {
if err == models.ErrAccessTokenNotExist {
- ctx.Handle(401, "invalid token", nil)
+ ctx.HandleText(401, "invalid token")
} else {
ctx.Handle(500, "GetAccessTokenBySha", err)
}
@@ -138,23 +138,23 @@ func Http(ctx *middleware.Context) {
has, err := models.HasAccess(authUser, repo, tp)
if err != nil {
- ctx.Handle(401, "no basic auth and digit auth", nil)
+ ctx.HandleText(401, "no basic auth and digit auth")
return
} else if !has {
if tp == models.ACCESS_MODE_READ {
has, err = models.HasAccess(authUser, repo, models.ACCESS_MODE_WRITE)
if err != nil || !has {
- ctx.Handle(401, "no basic auth and digit auth", nil)
+ ctx.HandleText(401, "no basic auth and digit auth")
return
}
} else {
- ctx.Handle(401, "no basic auth and digit auth", nil)
+ ctx.HandleText(401, "no basic auth and digit auth")
return
}
}
if !isPull && repo.IsMirror {
- ctx.Handle(401, "can't push to mirror", nil)
+ ctx.HandleText(401, "can't push to mirror")
return
}
}
@@ -190,7 +190,10 @@ func Http(ctx *middleware.Context) {
refName := fields[2]
// FIXME: handle error.
- models.Update(refName, oldCommitId, newCommitId, authUsername, username, reponame, authUser.Id)
+ if err = models.Update(refName, oldCommitId, newCommitId, authUsername, username, reponame, authUser.Id); err == nil {
+ models.HookQueue.AddRepoID(repo.Id)
+ }
+
}
lastLine = lastLine + size
} else {