diff --git a/routers/user/user.go b/routers/user/user.go index 7cd8bca550..cf1314086c 100644 --- a/routers/user/user.go +++ b/routers/user/user.go @@ -32,6 +32,14 @@ func SignIn(req *http.Request, r render.Render) { } // todo sign in + _, err := models.LoginUserPlain(req.FormValue("account"), req.FormValue("passwd")) + if err != nil { + r.HTML(200, "base/error", map[string]interface{}{ + "Error": fmt.Sprintf("%v", err), + }) + return + } + r.Redirect("/") } func SignUp(req *http.Request, r render.Render) { @@ -61,9 +69,16 @@ func SignUp(req *http.Request, r render.Render) { } err = models.RegisterUser(u) - r.HTML(403, "status/403", map[string]interface{}{ - "Title": fmt.Sprintf("%v", err), - }) + if err != nil { + if err != nil { + r.HTML(200, "base/error", map[string]interface{}{ + "Error": fmt.Sprintf("%v", err), + }) + return + } + } + + r.Redirect("/") } func Delete(req *http.Request, r render.Render) { diff --git a/templates/base/error.tmpl b/templates/base/error.tmpl new file mode 100644 index 0000000000..8d3c36be9a --- /dev/null +++ b/templates/base/error.tmpl @@ -0,0 +1,6 @@ +{{template "base/head" .}} +{{template "base/navbar" .}} +
+ An error is occupied : {{.Error}} +
+{{template "base/footer" .}} \ No newline at end of file diff --git a/templates/user/signin.tmpl b/templates/user/signin.tmpl index dcdeaa77c5..c3a3131f5d 100644 --- a/templates/user/signin.tmpl +++ b/templates/user/signin.tmpl @@ -1,7 +1,7 @@ {{template "base/head" .}} {{template "base/navbar" .}}
-
+

Log in