mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-27 06:03:51 +03: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) {
|
||||
if req.Method == "GET" {
|
||||
r.HTML(200, "user/signin", map[string]interface{}{
|
||||
"Title": "Log In",
|
||||
})
|
||||
return
|
||||
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)
|
||||
}
|
||||
|
||||
// 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("/")
|
||||
r.HTML(200, "user/signin", map[string]interface{}{
|
||||
"Title": "Log In",
|
||||
"Error": errString,
|
||||
"Account": account,
|
||||
})
|
||||
}
|
||||
|
||||
func SignUp(req *http.Request, r render.Render) {
|
||||
|
|
|
@ -2,17 +2,20 @@
|
|||
{{template "base/navbar" .}}
|
||||
<div class="container" id="gogs-body">
|
||||
<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">
|
||||
<label class="col-md-4 control-label">Username or Email: </label>
|
||||
<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 class="form-group">
|
||||
<label class="col-md-4 control-label">Password: </label>
|
||||
<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 class="form-group">
|
||||
|
|
Loading…
Reference in a new issue