mirror of
https://github.com/go-gitea/gitea
synced 2024-11-28 10:02:48 +01:00
display login error message when login post error
This commit is contained in:
parent
aad4856948
commit
d8a24aff8c
2 changed files with 25 additions and 18 deletions
|
@ -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 (
|
||||||
|
errString string
|
||||||
|
account string
|
||||||
|
)
|
||||||
|
if req.Method == "POST" {
|
||||||
|
account = req.FormValue("account")
|
||||||
|
_, err := models.LoginUserPlain(account, req.FormValue("passwd"))
|
||||||
|
if err == nil {
|
||||||
|
// login success
|
||||||
|
r.Redirect("/")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// login fail
|
||||||
|
errString = fmt.Sprintf("%v", err)
|
||||||
|
}
|
||||||
r.HTML(200, "user/signin", map[string]interface{}{
|
r.HTML(200, "user/signin", map[string]interface{}{
|
||||||
"Title": "Log In",
|
"Title": "Log In",
|
||||||
|
"Error": errString,
|
||||||
|
"Account": account,
|
||||||
})
|
})
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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) {
|
func SignUp(req *http.Request, r render.Render) {
|
||||||
|
|
|
@ -2,17 +2,20 @@
|
||||||
{{template "base/navbar" .}}
|
{{template "base/navbar" .}}
|
||||||
<div class="container" id="gogs-body">
|
<div class="container" id="gogs-body">
|
||||||
<form action="/user/signin" method="post" class="form-horizontal gogs-card" id="gogs-login-card">
|
<form action="/user/signin" method="post" class="form-horizontal gogs-card" id="gogs-login-card">
|
||||||
<h3>Log in</h3>
|
<h3>Log in</h3>{{if .Error}}
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-md-6 col-md-offset-3 alert alert-danger text-center"><strong>{{.Error}}</strong></div>
|
||||||
|
</div>{{end}}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-md-4 control-label">Username or Email: </label>
|
<label class="col-md-4 control-label">Username or Email: </label>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<input name="account" class="form-control" placeholder="Type your username or e-mail address">
|
<input name="account" class="form-control" placeholder="Type your username or e-mail address" value="{{.Account}}" required="required">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-md-4 control-label">Password: </label>
|
<label class="col-md-4 control-label">Password: </label>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<input name="passwd" type="password" class="form-control" placeholder="Type your password">
|
<input name="passwd" type="password" class="form-control" placeholder="Type your password" required="required">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
Loading…
Reference in a new issue