diff options
author | Unknown <joe2010xtmf@163.com> | 2014-06-05 22:07:35 -0400 |
---|---|---|
committer | Unknown <joe2010xtmf@163.com> | 2014-06-05 22:07:35 -0400 |
commit | 4f2f3c285717eff7a2f4ae2b79fbb0809e786dc8 (patch) | |
tree | 09e78d81573632b8638347c87d4f93d2f1c63f1b /routers/user/user.go | |
parent | 11f9d738e8a1bce4c35bc5e1c37f5a7d1bcded5c (diff) | |
download | gitea-4f2f3c285717eff7a2f4ae2b79fbb0809e786dc8.tar.gz gitea-4f2f3c285717eff7a2f4ae2b79fbb0809e786dc8.zip |
Code convention
Diffstat (limited to 'routers/user/user.go')
-rw-r--r-- | routers/user/user.go | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/routers/user/user.go b/routers/user/user.go index a5b3e79253..8fcbeb6a46 100644 --- a/routers/user/user.go +++ b/routers/user/user.go @@ -32,8 +32,8 @@ func SignIn(ctx *middleware.Context) { } // Check auto-login. - userName := ctx.GetCookie(setting.CookieUserName) - if len(userName) == 0 { + uname := ctx.GetCookie(setting.CookieUserName) + if len(uname) == 0 { ctx.HTML(200, "user/signin") return } @@ -41,14 +41,14 @@ func SignIn(ctx *middleware.Context) { isSucceed := false defer func() { if !isSucceed { - log.Trace("user.SignIn(auto-login cookie cleared): %s", userName) + log.Trace("user.SignIn(auto-login cookie cleared): %s", uname) ctx.SetCookie(setting.CookieUserName, "", -1) ctx.SetCookie(setting.CookieRememberName, "", -1) return } }() - user, err := models.GetUserByName(userName) + user, err := models.GetUserByName(uname) if err != nil { ctx.Handle(500, "user.SignIn(GetUserByName)", err) return @@ -90,7 +90,7 @@ func SignInPost(ctx *middleware.Context, form auth.LogInForm) { return } - user, err := models.LoginUser(form.UserName, form.Password) + user, err := models.UserSignIn(form.UserName, form.Password) if err != nil { if err == models.ErrUserNotExist { log.Trace("%s Log in failed: %s", ctx.Req.RequestURI, form.UserName) @@ -98,7 +98,7 @@ func SignInPost(ctx *middleware.Context, form auth.LogInForm) { return } - ctx.Handle(500, "user.SignIn", err) + ctx.Handle(500, "user.SignInPost(UserSignIn)", err) return } @@ -220,17 +220,18 @@ func SignUpPost(ctx *middleware.Context, form auth.RegisterForm) { if u, err = models.RegisterUser(u); err != nil { switch err { case models.ErrUserAlreadyExist: + ctx.Data["Err_UserName"] = true ctx.RenderWithErr("Username has been already taken", "user/signup", &form) case models.ErrEmailAlreadyUsed: + ctx.Data["Err_Email"] = true ctx.RenderWithErr("E-mail address has been already used", "user/signup", &form) case models.ErrUserNameIllegal: ctx.RenderWithErr(models.ErrRepoNameIllegal.Error(), "user/signup", &form) default: - ctx.Handle(500, "user.SignUp(RegisterUser)", err) + ctx.Handle(500, "user.SignUpPost(RegisterUser)", err) } return } - log.Trace("%s User created: %s", ctx.Req.RequestURI, form.UserName) // Bind social account. @@ -256,6 +257,7 @@ func SignUpPost(ctx *middleware.Context, form auth.RegisterForm) { } return } + ctx.Redirect("/user/login") } |