diff options
author | 6543 <6543@obermui.de> | 2020-12-25 09:59:32 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-25 11:59:32 +0200 |
commit | a19447aed128ecadfcd938d6a80cd4951af1f4ce (patch) | |
tree | 6312bf946d601aab29731645a4777feeaea66036 /models/login_source.go | |
parent | 04ae0f2f3f4556c6d0b4adc5f2cffd0cc7d25151 (diff) | |
download | gitea-a19447aed128ecadfcd938d6a80cd4951af1f4ce.tar.gz gitea-a19447aed128ecadfcd938d6a80cd4951af1f4ce.zip |
migrate from com.* to alternatives (#14103)
* remove github.com/unknwon/com from models
* dont use "com.ToStr()"
* replace "com.ToStr" with "fmt.Sprint" where its easy to do
* more refactor
* fix test
* just "proxy" Copy func for now
* as per @lunny
Diffstat (limited to 'models/login_source.go')
-rw-r--r-- | models/login_source.go | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/models/login_source.go b/models/login_source.go index 1de24a9cf7..4f577d6ca7 100644 --- a/models/login_source.go +++ b/models/login_source.go @@ -12,6 +12,7 @@ import ( "fmt" "net/smtp" "net/textproto" + "strconv" "strings" "code.gitea.io/gitea/modules/auth/ldap" @@ -20,8 +21,8 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/timeutil" + "code.gitea.io/gitea/modules/util" - "github.com/unknwon/com" "xorm.io/xorm" "xorm.io/xorm/convert" ) @@ -180,7 +181,9 @@ func Cell2Int64(val xorm.Cell) int64 { switch (*val).(type) { case []uint8: log.Trace("Cell2Int64 ([]uint8): %v", *val) - return com.StrTo(string((*val).([]uint8))).MustInt64() + + v, _ := strconv.ParseInt(string((*val).([]uint8)), 10, 64) + return v } return (*val).(int64) } @@ -200,7 +203,7 @@ func (source *LoginSource) BeforeSet(colName string, val xorm.Cell) { case LoginSSPI: source.Cfg = new(SSPIConfig) default: - panic("unrecognized login source type: " + com.ToStr(*val)) + panic(fmt.Sprintf("unrecognized login source type: %v", *val)) } } } @@ -610,7 +613,7 @@ func LoginViaSMTP(user *User, login, password string, sourceID int64, cfg *SMTPC idx := strings.Index(login, "@") if idx == -1 { return nil, ErrUserNotExist{0, login, 0} - } else if !com.IsSliceContainsStr(strings.Split(cfg.AllowedDomains, ","), login[idx+1:]) { + } else if !util.IsStringInSlice(login[idx+1:], strings.Split(cfg.AllowedDomains, ","), true) { return nil, ErrUserNotExist{0, login, 0} } } |