mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-24 00:03:11 -05:00
add oauth2 table init
This commit is contained in:
commit
c22d3503fd
3 changed files with 17 additions and 8 deletions
|
@ -18,7 +18,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
orm *xorm.Engine
|
orm *xorm.Engine
|
||||||
|
tables []interface{}
|
||||||
|
|
||||||
HasEngine bool
|
HasEngine bool
|
||||||
|
|
||||||
DbCfg struct {
|
DbCfg struct {
|
||||||
|
@ -28,6 +30,11 @@ var (
|
||||||
UseSQLite3 bool
|
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() {
|
func LoadModelsConfig() {
|
||||||
DbCfg.Type = base.Cfg.MustValue("database", "DB_TYPE")
|
DbCfg.Type = base.Cfg.MustValue("database", "DB_TYPE")
|
||||||
if DbCfg.Type == "sqlite3" {
|
if DbCfg.Type == "sqlite3" {
|
||||||
|
@ -58,9 +65,7 @@ func NewTestEngine(x *xorm.Engine) (err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("models.init(fail to conntect database): %v", err)
|
return fmt.Errorf("models.init(fail to conntect database): %v", err)
|
||||||
}
|
}
|
||||||
|
return x.Sync(tables...)
|
||||||
return x.Sync(new(User), new(PublicKey), new(Repository), new(Watch),
|
|
||||||
new(Action), new(Access), new(Issue), new(Comment))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetEngine() (err error) {
|
func SetEngine() (err error) {
|
||||||
|
@ -102,9 +107,9 @@ func SetEngine() (err error) {
|
||||||
func NewEngine() (err error) {
|
func NewEngine() (err error) {
|
||||||
if err = SetEngine(); err != nil {
|
if err = SetEngine(); err != nil {
|
||||||
return err
|
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 {
|
if err = orm.Sync(tables...); err != nil {
|
||||||
return fmt.Errorf("sync database struct error: %v", err)
|
return fmt.Errorf("sync database struct error: %v\n", err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
4
start.sh
4
start.sh
|
@ -1,5 +1,9 @@
|
||||||
#!/bin/bash -
|
#!/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
|
# start gogs web
|
||||||
#
|
#
|
||||||
cd "$(dirname $0)"
|
cd "$(dirname $0)"
|
||||||
|
|
2
web.go
2
web.go
|
@ -92,7 +92,7 @@ func runWeb(*cli.Context) {
|
||||||
m.Get("/avatar/:hash", avt.ServeHTTP)
|
m.Get("/avatar/:hash", avt.ServeHTTP)
|
||||||
|
|
||||||
m.Group("/user", func(r martini.Router) {
|
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("/login", binding.BindIgnErr(auth.LogInForm{}), user.SignIn)
|
||||||
r.Any("/sign_up", binding.BindIgnErr(auth.RegisterForm{}), user.SignUp)
|
r.Any("/sign_up", binding.BindIgnErr(auth.RegisterForm{}), user.SignUp)
|
||||||
}, reqSignOut)
|
}, reqSignOut)
|
||||||
|
|
Loading…
Reference in a new issue