diff options
author | skyblue <ssx205@gmail.com> | 2014-04-05 22:52:24 +0800 |
---|---|---|
committer | skyblue <ssx205@gmail.com> | 2014-04-05 22:52:24 +0800 |
commit | c22d3503fd65ec95fd215b395be059392bf90d87 (patch) | |
tree | c0ec2b4cd2bae6ce4f8e02e3dcc14add74658fb8 | |
parent | a92826a8feee904440d86fd851ac4ecce35520fd (diff) | |
parent | ce350a737a63aeb4e2ca5924adf28862a6a6cfb1 (diff) | |
download | gitea-c22d3503fd65ec95fd215b395be059392bf90d87.tar.gz gitea-c22d3503fd65ec95fd215b395be059392bf90d87.zip |
add oauth2 table init
-rw-r--r-- | models/models.go | 19 | ||||
-rwxr-xr-x | start.sh | 4 | ||||
-rw-r--r-- | web.go | 2 |
3 files changed, 17 insertions, 8 deletions
diff --git a/models/models.go b/models/models.go index 0ad863371c..ee96207d10 100644 --- a/models/models.go +++ b/models/models.go @@ -18,7 +18,9 @@ import ( ) var ( - orm *xorm.Engine + orm *xorm.Engine + tables []interface{} + HasEngine bool DbCfg struct { @@ -28,6 +30,11 @@ var ( UseSQLite3 bool ) +func init() { + tables = append(tables, new(User), new(PublicKey), new(Repository), new(Watch), + new(Action), new(Access), new(Issue), new(Comment), new(Oauth2)) +} + func LoadModelsConfig() { DbCfg.Type = base.Cfg.MustValue("database", "DB_TYPE") if DbCfg.Type == "sqlite3" { @@ -58,9 +65,7 @@ func NewTestEngine(x *xorm.Engine) (err error) { if err != nil { return fmt.Errorf("models.init(fail to conntect database): %v", err) } - - return x.Sync(new(User), new(PublicKey), new(Repository), new(Watch), - new(Action), new(Access), new(Issue), new(Comment)) + return x.Sync(tables...) } func SetEngine() (err error) { @@ -102,9 +107,9 @@ func SetEngine() (err error) { func NewEngine() (err error) { if err = SetEngine(); err != nil { return err - } else if err = orm.Sync(new(User), new(PublicKey), new(Repository), new(Watch), - new(Action), new(Access), new(Issue), new(Comment)); err != nil { - return fmt.Errorf("sync database struct error: %v", err) + } + if err = orm.Sync(tables...); err != nil { + return fmt.Errorf("sync database struct error: %v\n", err) } return nil } @@ -1,5 +1,9 @@ #!/bin/bash - # +# 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. +# # start gogs web # cd "$(dirname $0)" @@ -92,7 +92,7 @@ func runWeb(*cli.Context) { m.Get("/avatar/:hash", avt.ServeHTTP) m.Group("/user", func(r martini.Router) { - // r.Any("/login/github", user.SocialSignIn) + r.Any("/login/github", user.SocialSignIn) r.Any("/login", binding.BindIgnErr(auth.LogInForm{}), user.SignIn) r.Any("/sign_up", binding.BindIgnErr(auth.RegisterForm{}), user.SignUp) }, reqSignOut) |