diff --git a/bee.json b/bee.json index 7930694052..ce39670600 100644 --- a/bee.json +++ b/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": [] diff --git a/gogs.go b/gogs.go index c503a4af82..6cb3f37edd 100644 --- a/gogs.go +++ b/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"), diff --git a/models/access.go b/models/access.go index 11bb360afa..ea5cbfaa50 100644 --- a/models/access.go +++ b/models/access.go @@ -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, + }) } diff --git a/models/user.go b/models/user.go index 6ea329c526..44dadb9a5f 100644 --- a/models/user.go +++ b/models/user.go @@ -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 } diff --git a/routers/user/user.go b/routers/user/user.go new file mode 100644 index 0000000000..f9dc07f26d --- /dev/null +++ b/routers/user/user.go @@ -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), + }) +} diff --git a/templates/base/base.tmpl b/templates/base/base.tmpl deleted file mode 100644 index f75230d9af..0000000000 --- a/templates/base/base.tmpl +++ /dev/null @@ -1,15 +0,0 @@ - - -
- {{template "base/head" .}} - {{template "head" .}} - - - - {{template "base/navbar" .}} -