diff options
author | Unknwon <u@gogs.io> | 2016-01-11 14:34:32 +0800 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2016-01-11 14:34:32 +0800 |
commit | 91bab801aad337f2353cd4a46c896dfff6714cdf (patch) | |
tree | 8e5c5ab1e30507772e6b5feab149cad8275c28de /models | |
parent | 17c4400b1203db25d1458d0df3da1c17abe282c3 (diff) | |
download | gitea-91bab801aad337f2353cd4a46c896dfff6714cdf.tar.gz gitea-91bab801aad337f2353cd4a46c896dfff6714cdf.zip |
#2349 try to handle []int8 case
Diffstat (limited to 'models')
-rw-r--r-- | models/login.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/models/login.go b/models/login.go index e36171a342..dc620e1bca 100644 --- a/models/login.go +++ b/models/login.go @@ -105,10 +105,21 @@ type LoginSource struct { Updated time.Time `xorm:"UPDATED"` } +// Cell2Int64 converts a xorm.Cell type to int64, +// and handles possible irregular cases. +func Cell2Int64(val xorm.Cell) int64 { + switch (*val).(type) { + case []int8: + log.Trace("Cell2Int64 ([]int8): %v", *val) + return int64((*val).([]int8)[0]) + } + return (*val).(int64) +} + func (source *LoginSource) BeforeSet(colName string, val xorm.Cell) { switch colName { case "type": - switch LoginType((*val).(int64)) { + switch LoginType(Cell2Int64(val)) { case LOGIN_LDAP, LOGIN_DLDAP: source.Cfg = new(LDAPConfig) case LOGIN_SMTP: |