diff options
author | G <guillaume.dube.girard@gmail.com> | 2017-08-01 01:47:31 -0400 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2017-08-01 13:47:31 +0800 |
commit | 66e8262530fb7906a3f8f5933fd6dbd6152bf898 (patch) | |
tree | d596a9572d8a345224a5a1cc3334887cdff99a1a /models/oauth2.go | |
parent | 31411a9462533abb0ca0866c2dccfd9b1ddf553e (diff) | |
download | gitea-66e8262530fb7906a3f8f5933fd6dbd6152bf898.tar.gz gitea-66e8262530fb7906a3f8f5933fd6dbd6152bf898.zip |
Replace calls to xorm UseBool with Where (#2237)
Diffstat (limited to 'models/oauth2.go')
-rw-r--r-- | models/oauth2.go | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/models/oauth2.go b/models/oauth2.go index 158f52b963..a1917540d0 100644 --- a/models/oauth2.go +++ b/models/oauth2.go @@ -56,7 +56,7 @@ var OAuth2DefaultCustomURLMappings = map[string]*oauth2.CustomURLMapping{ // GetActiveOAuth2ProviderLoginSources returns all actived LoginOAuth2 sources func GetActiveOAuth2ProviderLoginSources() ([]*LoginSource, error) { sources := make([]*LoginSource, 0, 1) - if err := x.UseBool().Find(&sources, &LoginSource{IsActived: true, Type: LoginOAuth2}); err != nil { + if err := x.Where("is_actived = ? and type = ?", true, LoginOAuth2).Find(&sources); err != nil { return nil, err } return sources, nil @@ -64,13 +64,8 @@ func GetActiveOAuth2ProviderLoginSources() ([]*LoginSource, error) { // GetActiveOAuth2LoginSourceByName returns a OAuth2 LoginSource based on the given name func GetActiveOAuth2LoginSourceByName(name string) (*LoginSource, error) { - loginSource := &LoginSource{ - Name: name, - Type: LoginOAuth2, - IsActived: true, - } - - has, err := x.UseBool().Get(loginSource) + loginSource := new(LoginSource) + has, err := x.Where("name = ? and type = ? and is_actived = ?", name, LoginOAuth2, true).Get(loginSource) if !has || err != nil { return nil, err } |