diff options
author | Unknwon <u@gogs.io> | 2015-08-05 11:14:17 +0800 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-08-05 11:14:17 +0800 |
commit | e50982f5ec78c3cfa4a1cf322f7fa1a4dea44b84 (patch) | |
tree | f6dffcf1c5a273a077a8b33c75334b9994ca02ff /routers | |
parent | 487fc8ca39a3de565fc6c67aea72c4658bbf64c8 (diff) | |
download | gitea-e50982f5ec78c3cfa4a1cf322f7fa1a4dea44b84.tar.gz gitea-e50982f5ec78c3cfa4a1cf322f7fa1a4dea44b84.zip |
allow anonymous SSH clone
Diffstat (limited to 'routers')
-rw-r--r-- | routers/api/v1/repo.go | 6 | ||||
-rw-r--r-- | routers/api/v1/user.go | 2 | ||||
-rw-r--r-- | routers/org/members.go | 2 | ||||
-rw-r--r-- | routers/org/teams.go | 2 | ||||
-rw-r--r-- | routers/repo/http.go | 4 | ||||
-rw-r--r-- | routers/repo/repo.go | 2 | ||||
-rw-r--r-- | routers/repo/setting.go | 6 | ||||
-rw-r--r-- | routers/user/auth.go | 8 | ||||
-rw-r--r-- | routers/user/home.go | 14 |
9 files changed, 23 insertions, 23 deletions
diff --git a/routers/api/v1/repo.go b/routers/api/v1/repo.go index 7da5f81731..d683eac3f9 100644 --- a/routers/api/v1/repo.go +++ b/routers/api/v1/repo.go @@ -139,7 +139,7 @@ func CreateRepo(ctx *middleware.Context, opt api.CreateRepoOption) { func CreateOrgRepo(ctx *middleware.Context, opt api.CreateRepoOption) { org, err := models.GetOrgByName(ctx.Params(":org")) if err != nil { - if err == models.ErrUserNotExist { + if models.IsErrUserNotExist(err) { ctx.Error(404) } else { ctx.Error(500) @@ -157,7 +157,7 @@ func CreateOrgRepo(ctx *middleware.Context, opt api.CreateRepoOption) { func MigrateRepo(ctx *middleware.Context, form auth.MigrateRepoForm) { u, err := models.GetUserByName(ctx.Query("username")) if err != nil { - if err == models.ErrUserNotExist { + if models.IsErrUserNotExist(err) { ctx.HandleAPI(422, err) } else { ctx.HandleAPI(500, err) @@ -174,7 +174,7 @@ func MigrateRepo(ctx *middleware.Context, form auth.MigrateRepoForm) { if form.Uid != u.Id { org, err := models.GetUserById(form.Uid) if err != nil { - if err == models.ErrUserNotExist { + if models.IsErrUserNotExist(err) { ctx.HandleAPI(422, err) } else { ctx.HandleAPI(500, err) diff --git a/routers/api/v1/user.go b/routers/api/v1/user.go index a4648297b9..feecda483d 100644 --- a/routers/api/v1/user.go +++ b/routers/api/v1/user.go @@ -61,7 +61,7 @@ func SearchUsers(ctx *middleware.Context) { func GetUserInfo(ctx *middleware.Context) { u, err := models.GetUserByName(ctx.Params(":username")) if err != nil { - if err == models.ErrUserNotExist { + if models.IsErrUserNotExist(err) { ctx.Error(404) } else { ctx.JSON(500, &base.ApiJsonErr{"GetUserByName: " + err.Error(), base.DOC_URL}) diff --git a/routers/org/members.go b/routers/org/members.go index c8c90cfe48..dd742bb7a2 100644 --- a/routers/org/members.go +++ b/routers/org/members.go @@ -100,7 +100,7 @@ func Invitation(ctx *middleware.Context) { uname := ctx.Query("uname") u, err := models.GetUserByName(uname) if err != nil { - if err == models.ErrUserNotExist { + if models.IsErrUserNotExist(err) { ctx.Flash.Error(ctx.Tr("form.user_not_exist")) ctx.Redirect(ctx.Org.OrgLink + "/invitations/new") } else { diff --git a/routers/org/teams.go b/routers/org/teams.go index 7436e30ee0..6968512fed 100644 --- a/routers/org/teams.go +++ b/routers/org/teams.go @@ -77,7 +77,7 @@ func TeamsAction(ctx *middleware.Context) { var u *models.User u, err = models.GetUserByName(uname) if err != nil { - if err == models.ErrUserNotExist { + if models.IsErrUserNotExist(err) { ctx.Flash.Error(ctx.Tr("form.user_not_exist")) ctx.Redirect(ctx.Org.OrgLink + "/teams/" + ctx.Org.Team.LowerName) } else { diff --git a/routers/repo/http.go b/routers/repo/http.go index 4e5aba04e0..45b0ec59c9 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) @@ -107,7 +107,7 @@ func Http(ctx *middleware.Context) { 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 } diff --git a/routers/repo/repo.go b/routers/repo/repo.go index 605071d110..f8df726cb6 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -35,7 +35,7 @@ func checkContextUser(ctx *middleware.Context, uid int64) *models.User { } org, err := models.GetUserById(uid) - if err == models.ErrUserNotExist { + if models.IsErrUserNotExist(err) { return ctx.User } diff --git a/routers/repo/setting.go b/routers/repo/setting.go index c371480816..12fc428c1d 100644 --- a/routers/repo/setting.go +++ b/routers/repo/setting.go @@ -118,7 +118,7 @@ func SettingsPost(ctx *middleware.Context, form auth.RepoSettingForm) { } if _, err = models.UserSignIn(ctx.User.Name, ctx.Query("password")); err != nil { - if err == models.ErrUserNotExist { + if models.IsErrUserNotExist(err) { ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_password"), SETTINGS_OPTIONS, nil) } else { ctx.Handle(500, "UserSignIn", err) @@ -151,7 +151,7 @@ func SettingsPost(ctx *middleware.Context, form auth.RepoSettingForm) { } if _, err := models.UserSignIn(ctx.User.Name, ctx.Query("password")); err != nil { - if err == models.ErrUserNotExist { + if models.IsErrUserNotExist(err) { ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_password"), SETTINGS_OPTIONS, nil) } else { ctx.Handle(500, "UserSignIn", err) @@ -185,7 +185,7 @@ func SettingsCollaboration(ctx *middleware.Context) { u, err := models.GetUserByName(name) if err != nil { - if err == models.ErrUserNotExist { + if models.IsErrUserNotExist(err) { ctx.Flash.Error(ctx.Tr("form.user_not_exist")) ctx.Redirect(setting.AppSubUrl + ctx.Req.URL.Path) } else { diff --git a/routers/user/auth.go b/routers/user/auth.go index 52675a777d..4b29a29ec8 100644 --- a/routers/user/auth.go +++ b/routers/user/auth.go @@ -60,7 +60,7 @@ func SignIn(ctx *middleware.Context) { u, err := models.GetUserByName(uname) if err != nil { - if err != models.ErrUserNotExist { + if !models.IsErrUserNotExist(err) { ctx.Handle(500, "GetUserByName", err) } else { ctx.HTML(200, SIGNIN) @@ -105,7 +105,7 @@ func SignInPost(ctx *middleware.Context, form auth.SignInForm) { u, err := models.UserSignIn(form.UserName, form.Password) if err != nil { - if err == models.ErrUserNotExist { + if models.IsErrUserNotExist(err) { ctx.RenderWithErr(ctx.Tr("form.username_password_incorrect"), SIGNIN, &form) } else { ctx.Handle(500, "UserSignIn", err) @@ -328,7 +328,7 @@ func Activate(ctx *middleware.Context) { user.IsActive = true user.Rands = models.GetUserSalt() if err := models.UpdateUser(user); err != nil { - if err == models.ErrUserNotExist { + if models.IsErrUserNotExist(err) { ctx.Error(404) } else { ctx.Handle(500, "UpdateUser", err) @@ -391,7 +391,7 @@ func ForgotPasswdPost(ctx *middleware.Context) { email := ctx.Query("email") u, err := models.GetUserByEmail(email) if err != nil { - if err == models.ErrUserNotExist { + if models.IsErrUserNotExist(err) { ctx.Data["Err_Email"] = true ctx.RenderWithErr(ctx.Tr("auth.email_not_associate"), FORGOT_PASSWORD, nil) } else { diff --git a/routers/user/home.go b/routers/user/home.go index 503f9e3667..5e77b837f8 100644 --- a/routers/user/home.go +++ b/routers/user/home.go @@ -38,7 +38,7 @@ func Dashboard(ctx *middleware.Context) { // Organization. org, err := models.GetUserByName(orgName) if err != nil { - if err == models.ErrUserNotExist { + if models.IsErrUserNotExist(err) { ctx.Handle(404, "GetUserByName", err) } else { ctx.Handle(500, "GetUserByName", err) @@ -115,7 +115,7 @@ func Dashboard(ctx *middleware.Context) { // FIXME: cache results? u, err := models.GetUserByName(act.ActUserName) if err != nil { - if err == models.ErrUserNotExist { + if models.IsErrUserNotExist(err) { continue } ctx.Handle(500, "GetUserByName", err) @@ -176,7 +176,7 @@ func Profile(ctx *middleware.Context) { u, err := models.GetUserByName(uname) if err != nil { - if err == models.ErrUserNotExist { + if models.IsErrUserNotExist(err) { ctx.Handle(404, "GetUserByName", err) } else { ctx.Handle(500, "GetUserByName", err) @@ -223,7 +223,7 @@ func Profile(ctx *middleware.Context) { // FIXME: cache results? u, err := models.GetUserByName(act.ActUserName) if err != nil { - if err == models.ErrUserNotExist { + if models.IsErrUserNotExist(err) { continue } ctx.Handle(500, "GetUserByName", err) @@ -247,10 +247,10 @@ func Profile(ctx *middleware.Context) { func Email2User(ctx *middleware.Context) { u, err := models.GetUserByEmail(ctx.Query("email")) if err != nil { - if err == models.ErrUserNotExist { - ctx.Handle(404, "user.Email2User(GetUserByEmail)", err) + if models.IsErrUserNotExist(err) { + ctx.Handle(404, "GetUserByEmail", err) } else { - ctx.Handle(500, "user.Email2User(GetUserByEmail)", err) + ctx.Handle(500, "GetUserByEmail", err) } return } |