mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-22 22:24:03 +01:00
finished signin and login
This commit is contained in:
parent
c4c23b3f79
commit
c5132b87a6
3 changed files with 25 additions and 4 deletions
|
@ -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) {
|
||||
|
|
6
templates/base/error.tmpl
Normal file
6
templates/base/error.tmpl
Normal file
|
@ -0,0 +1,6 @@
|
|||
{{template "base/head" .}}
|
||||
{{template "base/navbar" .}}
|
||||
<div id="gogs-body" class="container">
|
||||
An error is occupied : {{.Error}}
|
||||
</div>
|
||||
{{template "base/footer" .}}
|
|
@ -1,7 +1,7 @@
|
|||
{{template "base/head" .}}
|
||||
{{template "base/navbar" .}}
|
||||
<div class="container" id="gogs-body">
|
||||
<form action="/user/signup" method="post" class="form-horizontal" id="gogs-login-card">
|
||||
<form action="/user/signin" method="post" class="form-horizontal" id="gogs-login-card">
|
||||
<h3>Log in</h3>
|
||||
<div class="form-group">
|
||||
<label class="col-md-4 control-label">Username or Email: </label>
|
||||
|
|
Loading…
Reference in a new issue