aboutsummaryrefslogtreecommitdiffstats
path: root/modules/auth/auth.go
diff options
context:
space:
mode:
authorUnknwon <joe2010xtmf@163.com>2015-02-01 12:41:03 -0500
committerUnknwon <joe2010xtmf@163.com>2015-02-01 12:41:03 -0500
commitb293b6eaa6b305bbac2147f76d5722607e8aa04b (patch)
tree92e60483c65594729b7bbcf60ca9d15b1932be1f /modules/auth/auth.go
parent3d9cda2d98940102b1bdffc053e036cc696b9f8e (diff)
downloadgitea-b293b6eaa6b305bbac2147f76d5722607e8aa04b.tar.gz
gitea-b293b6eaa6b305bbac2147f76d5722607e8aa04b.zip
cmd: CMD option for port number of `gogs web` to prevent first time run conflict
- routers: use new binding convention to simplify code - templates: able to set HTTP port number in install page
Diffstat (limited to 'modules/auth/auth.go')
-rw-r--r--modules/auth/auth.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/modules/auth/auth.go b/modules/auth/auth.go
index 1dd96d8d40..ad7ce5b9ad 100644
--- a/modules/auth/auth.go
+++ b/modules/auth/auth.go
@@ -9,6 +9,7 @@ import (
"reflect"
"strings"
+ "github.com/Unknwon/com"
"github.com/Unknwon/macaron"
"github.com/macaron-contrib/binding"
"github.com/macaron-contrib/session"
@@ -135,6 +136,10 @@ type Form interface {
binding.Validator
}
+func init() {
+ binding.SetNameMapper(com.ToSnakeCase)
+}
+
// AssignForm assign form values back to the template data.
func AssignForm(form interface{}, data map[string]interface{}) {
typ := reflect.TypeOf(form)
@@ -152,6 +157,8 @@ func AssignForm(form interface{}, data map[string]interface{}) {
// Allow ignored fields in the struct
if fieldName == "-" {
continue
+ } else if len(fieldName) == 0 {
+ fieldName = com.ToSnakeCase(field.Name)
}
data[fieldName] = val.Field(i).Interface()