aboutsummaryrefslogtreecommitdiff
path: root/modules/base
diff options
context:
space:
mode:
Diffstat (limited to 'modules/base')
-rw-r--r--modules/base/conf.go7
-rw-r--r--modules/base/template.go8
2 files changed, 12 insertions, 3 deletions
diff --git a/modules/base/conf.go b/modules/base/conf.go
index fd77cfd3..f696d083 100644
--- a/modules/base/conf.go
+++ b/modules/base/conf.go
@@ -272,18 +272,19 @@ func NewConfigContext() {
Domain = Cfg.MustValue("server", "DOMAIN")
SecretKey = Cfg.MustValue("security", "SECRET_KEY")
+ InstallLock = Cfg.MustBool("security", "INSTALL_LOCK", false)
+
RunUser = Cfg.MustValue("", "RUN_USER")
curUser := os.Getenv("USERNAME")
if len(curUser) == 0 {
curUser = os.Getenv("USER")
}
- if RunUser != curUser {
+ // Does not check run user when the install lock is off.
+ if InstallLock && RunUser != curUser {
fmt.Printf("Expect user(%s) but current user is: %s\n", RunUser, curUser)
os.Exit(2)
}
- InstallLock = Cfg.MustBool("security", "INSTALL_LOCK", false)
-
LogInRememberDays = Cfg.MustInt("security", "LOGIN_REMEMBER_DAYS")
CookieUserName = Cfg.MustValue("security", "COOKIE_USERNAME")
CookieRememberName = Cfg.MustValue("security", "COOKIE_REMEMBER_NAME")
diff --git a/modules/base/template.go b/modules/base/template.go
index dca76faf..dfcae931 100644
--- a/modules/base/template.go
+++ b/modules/base/template.go
@@ -33,6 +33,13 @@ func List(l *list.List) chan interface{} {
return c
}
+func ShortSha(sha1 string) string {
+ if len(sha1) == 40 {
+ return sha1[:10]
+ }
+ return sha1
+}
+
var mailDomains = map[string]string{
"gmail.com": "gmail.com",
}
@@ -72,4 +79,5 @@ var TemplateFuncs template.FuncMap = map[string]interface{}{
},
"DiffTypeToStr": DiffTypeToStr,
"DiffLineTypeToStr": DiffLineTypeToStr,
+ "ShortSha": ShortSha,
}