1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Add postgres support, clean code, code review

This commit is contained in:
Unknown
2014-03-17 14:03:58 -04:00
parent 9d3b003add
commit e51afe4621
19 changed files with 1124 additions and 303 deletions

View File

@@ -18,6 +18,7 @@ import (
"github.com/gogits/gogs/modules/log"
)
// SignedInId returns the id of signed in user.
func SignedInId(session sessions.Session) int64 {
userId := session.Get("userId")
if userId == nil {
@@ -32,6 +33,7 @@ func SignedInId(session sessions.Session) int64 {
return 0
}
// SignedInName returns the name of signed in user.
func SignedInName(session sessions.Session) string {
userName := session.Get("userName")
if userName == nil {
@@ -43,6 +45,7 @@ func SignedInName(session sessions.Session) string {
return ""
}
// SignedInUser returns the user object of signed user.
func SignedInUser(session sessions.Session) *models.User {
id := SignedInId(session)
if id <= 0 {
@@ -57,6 +60,7 @@ func SignedInUser(session sessions.Session) *models.User {
return user
}
// IsSignedIn check if any user has signed in.
func IsSignedIn(session sessions.Session) bool {
return SignedInId(session) > 0
}

View File

@@ -4,8 +4,6 @@
package base
import ()
type (
// Type TmplData represents data in the templates.
TmplData map[string]interface{}

View File

@@ -48,6 +48,7 @@ func init() {
fmt.Printf("Cannot load config file '%s'\n", cfgPath)
os.Exit(2)
}
Cfg.BlockMode = false
cfgPath = filepath.Join(workDir, "custom/conf/app.ini")
if com.IsFile(cfgPath) {

View File

@@ -8,6 +8,7 @@ import (
"github.com/codegangsta/martini"
)
// SignInRequire requires user to sign in.
func SignInRequire(redirect bool) martini.Handler {
return func(ctx *Context) {
if !ctx.IsSigned {
@@ -19,6 +20,7 @@ func SignInRequire(redirect bool) martini.Handler {
}
}
// SignOutRequire requires user to sign out.
func SignOutRequire() martini.Handler {
return func(ctx *Context) {
if ctx.IsSigned {