diff options
author | Unknown <joe2010xtmf@163.com> | 2014-03-03 19:03:08 -0500 |
---|---|---|
committer | Unknown <joe2010xtmf@163.com> | 2014-03-03 19:03:08 -0500 |
commit | e59f90b8fee3e615d1b60067bfc0d636606899d8 (patch) | |
tree | e37db19d1492235875259f34ed08506f74631270 /routers | |
parent | fea660f1d787f353f06632982861000c9078da2e (diff) | |
download | gitea-e59f90b8fee3e615d1b60067bfc0d636606899d8.tar.gz gitea-e59f90b8fee3e615d1b60067bfc0d636606899d8.zip |
Update
Diffstat (limited to 'routers')
-rw-r--r-- | routers/user/user.go | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/routers/user/user.go b/routers/user/user.go index 5dc2c0b97d..a66a7b5f94 100644 --- a/routers/user/user.go +++ b/routers/user/user.go @@ -14,6 +14,7 @@ import ( "github.com/gogits/validation" "github.com/gogits/gogs/models" + "github.com/gogits/gogs/utils/auth" "github.com/gogits/gogs/utils/log" ) @@ -50,18 +51,19 @@ func SignIn(req *http.Request, r render.Render, session sessions.Session) { } func SignUp(req *http.Request, r render.Render) { + data := map[string]interface{}{"Title": "Sign Up"} if req.Method == "GET" { - r.HTML(200, "user/signup", map[string]interface{}{ - "Title": "Sign Up", - }) + r.HTML(200, "user/signup", data) return } + // Front-end should do double check of password. u := &models.User{ Name: req.FormValue("username"), Email: req.FormValue("email"), Passwd: req.FormValue("passwd"), } + valid := validation.Validation{} ok, err := valid.Valid(u) if err != nil { @@ -69,23 +71,21 @@ func SignUp(req *http.Request, r render.Render) { return } if !ok { - for _, err := range valid.Errors { - log.Warn("user.SignUp -> valid user: %v", err) - } + data["HasError"] = true + data["ErrorMsg"] = auth.GenerateErrorMsg(valid.Errors[0]) + r.HTML(200, "user/signup", data) return } - err = models.RegisterUser(u) - if err != nil { - if err != nil { - r.HTML(200, "base/error", map[string]interface{}{ - "Error": fmt.Sprintf("%v", err), - }) - return - } - } + // err = models.RegisterUser(u) + // if err != nil { + // r.HTML(200, "base/error", map[string]interface{}{ + // "Error": fmt.Sprintf("%v", err), + // }) + // return + // } - r.Redirect("/") + // r.Redirect("/") } func Delete(req *http.Request, r render.Render) { |