|
|
@ -24,22 +24,26 @@ func Profile(r render.Render) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func SignIn(req *http.Request, r render.Render) { |
|
|
|
func SignIn(req *http.Request, r render.Render) { |
|
|
|
if req.Method == "GET" { |
|
|
|
var ( |
|
|
|
r.HTML(200, "user/signin", map[string]interface{}{ |
|
|
|
errString string |
|
|
|
"Title": "Log In", |
|
|
|
account string |
|
|
|
}) |
|
|
|
) |
|
|
|
return |
|
|
|
if req.Method == "POST" { |
|
|
|
} |
|
|
|
account = req.FormValue("account") |
|
|
|
|
|
|
|
_, err := models.LoginUserPlain(account, req.FormValue("passwd")) |
|
|
|
// todo sign in
|
|
|
|
if err == nil { |
|
|
|
_, err := models.LoginUserPlain(req.FormValue("account"), req.FormValue("passwd")) |
|
|
|
// login success
|
|
|
|
if err != nil { |
|
|
|
r.Redirect("/") |
|
|
|
r.HTML(200, "base/error", map[string]interface{}{ |
|
|
|
return |
|
|
|
"Error": fmt.Sprintf("%v", err), |
|
|
|
} |
|
|
|
}) |
|
|
|
// login fail
|
|
|
|
return |
|
|
|
errString = fmt.Sprintf("%v", err) |
|
|
|
} |
|
|
|
} |
|
|
|
r.Redirect("/") |
|
|
|
r.HTML(200, "user/signin", map[string]interface{}{ |
|
|
|
|
|
|
|
"Title": "Log In", |
|
|
|
|
|
|
|
"Error": errString, |
|
|
|
|
|
|
|
"Account": account, |
|
|
|
|
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func SignUp(req *http.Request, r render.Render) { |
|
|
|
func SignUp(req *http.Request, r render.Render) { |
|
|
|