mirror of
https://github.com/go-gitea/gitea
synced 2024-12-22 04:57:51 +01:00
Add UI for register user
This commit is contained in:
parent
5da2ad7435
commit
3eb1ab9e8b
5
bee.json
5
bee.json
@ -7,9 +7,12 @@
|
||||
"go_install": true,
|
||||
"watch_ext": [],
|
||||
"dir_structure": {
|
||||
"watch_all": true,
|
||||
"controllers": "routers",
|
||||
"models": "",
|
||||
"others": []
|
||||
"others": [
|
||||
"utils"
|
||||
]
|
||||
},
|
||||
"cmd_args": [],
|
||||
"envs": []
|
||||
|
7
gogs.go
7
gogs.go
@ -12,18 +12,19 @@ import (
|
||||
"github.com/martini-contrib/render"
|
||||
|
||||
"github.com/gogits/gogs/routers"
|
||||
"github.com/gogits/gogs/routers/user"
|
||||
"github.com/gogits/gogs/utils"
|
||||
"github.com/gogits/gogs/utils/log"
|
||||
)
|
||||
|
||||
const APP_VER = "0.0.0.0212"
|
||||
const APP_VER = "0.0.0.0217"
|
||||
|
||||
func init() {
|
||||
|
||||
}
|
||||
|
||||
func main() {
|
||||
log.Info("App Name: %s", utils.Cfg.MustValue("", "APP_NAME"))
|
||||
log.Info("%s %s", utils.Cfg.MustValue("", "APP_NAME"), APP_VER)
|
||||
|
||||
m := martini.Classic()
|
||||
|
||||
@ -32,6 +33,8 @@ func main() {
|
||||
|
||||
// Routers.
|
||||
m.Get("/", routers.Dashboard)
|
||||
m.Get("/user/signin", user.SignIn)
|
||||
m.Any("/user/signup", user.SignUp)
|
||||
|
||||
listenAddr := fmt.Sprintf("%s:%s",
|
||||
utils.Cfg.MustValue("server", "HTTP_ADDR"),
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
@ -6,8 +10,8 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
Readable = iota + 1
|
||||
Writable
|
||||
AU_READABLE = iota + 1
|
||||
AU_WRITABLE
|
||||
)
|
||||
|
||||
type Access struct {
|
||||
@ -24,6 +28,11 @@ func AddAccess(access *Access) error {
|
||||
}
|
||||
|
||||
// if one user can read or write one repository
|
||||
func HasAccess(userName, repoName, mode string) (bool, error) {
|
||||
return orm.Get(&Access{0, strings.ToLower(userName), strings.ToLower(repoName), mode})
|
||||
func HasAccess(userName, repoName string, mode int) (bool, error) {
|
||||
return orm.Get(&Access{
|
||||
Id: 0,
|
||||
UserName: strings.ToLower(userName),
|
||||
RepoName: strings.ToLower(repoName),
|
||||
Mode: mode,
|
||||
})
|
||||
}
|
||||
|
@ -98,6 +98,10 @@ func RegisterUser(user *User) (err error) {
|
||||
if err = validateUser(user.Name); err != nil {
|
||||
return err
|
||||
}
|
||||
user.LowerName = strings.ToLower(user.Name)
|
||||
// TODO: generate Avatar address.
|
||||
user.Created = time.Now()
|
||||
user.Updated = time.Now()
|
||||
_, err = orm.Insert(user)
|
||||
return err
|
||||
}
|
||||
|
38
routers/user/user.go
Normal file
38
routers/user/user.go
Normal file
@ -0,0 +1,38 @@
|
||||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package user
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/martini-contrib/render"
|
||||
|
||||
//"github.com/gogits/gogs/utils/log"
|
||||
"github.com/gogits/gogs/models"
|
||||
)
|
||||
|
||||
func SignIn(r render.Render) {
|
||||
r.Redirect("/user/signup", 302)
|
||||
}
|
||||
|
||||
func SignUp(req *http.Request, r render.Render) {
|
||||
if req.Method == "GET" {
|
||||
r.HTML(200, "user/signup", map[string]interface{}{
|
||||
"Title": "Sign Up",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// TODO: validate form.
|
||||
err := models.RegisterUser(&models.User{
|
||||
Name: req.FormValue("username"),
|
||||
Email: req.FormValue("email"),
|
||||
Passwd: req.FormValue("passwd"),
|
||||
})
|
||||
r.HTML(403, "status/403", map[string]interface{}{
|
||||
"Title": fmt.Sprintf("%v", err),
|
||||
})
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
{{template "base/head" .}}
|
||||
{{template "head" .}}
|
||||
</head>
|
||||
<body>
|
||||
<noscript>Please enable JavaScript in your browser!</noscript>
|
||||
{{template "base/navbar" .}}
|
||||
<div class="container">
|
||||
{{template "body" .}}
|
||||
</div>
|
||||
{{template "base/footer" .}}
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,2 @@
|
||||
</body>
|
||||
</html>
|
@ -1,14 +1,22 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<link rel="shortcut icon" href="img/favicon.png" />
|
||||
<meta name="author" content="Gogs - Go Git Service" />
|
||||
<meta name="description" content="Gogs(Go Git Service) is a GitHub-like clone in the Go Programming Language" />
|
||||
<meta name="keywords" content="go, git">
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<link rel="shortcut icon" href="/img/favicon.png" />
|
||||
<meta name="author" content="Gogs - Go Git Service" />
|
||||
<meta name="description" content="Gogs(Go Git Service) is a GitHub-like clone in the Go Programming Language" />
|
||||
<meta name="keywords" content="go, git">
|
||||
|
||||
<!-- Stylesheets -->
|
||||
<link href="css/bootstrap.min.css" rel="stylesheet" />
|
||||
<link href="css/todc-bootstrap.min.css" rel="stylesheet" />
|
||||
<link href="css/font-awesome.min.css" rel="stylesheet" />
|
||||
<link href="css/gogs.css" rel="stylesheet" />
|
||||
<!-- Stylesheets -->
|
||||
<link href="/css/bootstrap.min.css" rel="stylesheet" />
|
||||
<link href="/css/todc-bootstrap.min.css" rel="stylesheet" />
|
||||
<link href="/css/font-awesome.min.css" rel="stylesheet" />
|
||||
<link href="/css/gogs.css" rel="stylesheet" />
|
||||
|
||||
<script src="js/jquery-1.10.1.min.js"></script>
|
||||
<script src="js/bootstrap.min.js"></script>
|
||||
<script src="/js/jquery-1.10.1.min.js"></script>
|
||||
<script src="/js/bootstrap.min.js"></script>
|
||||
|
||||
<title>{{.Title}} | Gogs - Go Git Service</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>Please enable JavaScript in your browser!</noscript>
|
@ -4,7 +4,7 @@
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#gogs-navbar-collapse">
|
||||
<i class="fa fa-bars"></i>
|
||||
</button>
|
||||
<a class="navbar-brand" href="/"><img src="img/favicon.png" alt="Gogs Logo"></a>
|
||||
<a class="navbar-brand" href="/"><img src="/img/favicon.png" alt="Gogs Logo"></a>
|
||||
</div>
|
||||
|
||||
<div class="collapse navbar-collapse" id="gopmweb-navbar-collapse">
|
||||
@ -12,7 +12,7 @@
|
||||
<li><a>{{.Title}}</a></li>
|
||||
</ul>
|
||||
|
||||
<a href="/login" class="navbar-right btn btn-success navbar-btn">Log In</a>
|
||||
<a href="/user/signin" class="navbar-right btn btn-success navbar-btn">Sign In</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
@ -1,5 +1,6 @@
|
||||
{{template "base/base" .}}
|
||||
{{define "head"}} <title>{{.Title}} | Gogs - Go Git Service</title>{{end}}
|
||||
{{define "body"}}
|
||||
Website is still in the progress of building...please come back later!
|
||||
{{end}}
|
||||
{{template "base/head" .}}
|
||||
{{template "base/navbar" .}}
|
||||
<div class="container">
|
||||
Website is still in the progress of building...please come back later!
|
||||
</div>
|
||||
{{template "base/footer" .}}
|
6
templates/status/403.tmpl
Normal file
6
templates/status/403.tmpl
Normal file
@ -0,0 +1,6 @@
|
||||
{{template "base/head" .}}
|
||||
{{template "base/navbar" .}}
|
||||
<div class="container">
|
||||
403 Forbidden
|
||||
</div>
|
||||
{{template "base/footer" .}}
|
44
templates/user/signup.tmpl
Normal file
44
templates/user/signup.tmpl
Normal file
@ -0,0 +1,44 @@
|
||||
{{template "base/head" .}}
|
||||
{{template "base/navbar" .}}
|
||||
<div class="container">
|
||||
<form action="/user/signup" method="post" class="form-horizontal">
|
||||
<div class="form-group">
|
||||
<label class="col-md-4 control-label">Username: </label>
|
||||
<div class="col-md-3">
|
||||
<input name="username" class="form-control" placeholder="Type your username">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-md-4 control-label">Email: </label>
|
||||
<div class="col-md-3">
|
||||
<input name="email" class="form-control" placeholder="Type your e-mail address">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-md-4 control-label">Password: </label>
|
||||
<div class="col-md-3">
|
||||
<input name="passwd" type="password" class="form-control" placeholder="Type your password">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-md-4 control-label">Re-type: </label>
|
||||
<div class="col-md-3">
|
||||
<input type="password" class="form-control" placeholder="Re-type your password">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-offset-4 col-md-3">
|
||||
<button type="submit" class="btn btn-info">Sign Up</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-offset-4 col-md-3">
|
||||
<a href="/user/signin">Already have an account? Sign in now!</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{{template "base/footer" .}}
|
Loading…
Reference in New Issue
Block a user