1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-12-21 12:44:49 -05:00

Replace calls to xorm UseBool with Where (#2237)

This commit is contained in:
G 2017-08-01 01:47:31 -04:00 committed by Lunny Xiao
parent 31411a9462
commit 66e8262530
2 changed files with 4 additions and 9 deletions

View file

@ -677,7 +677,7 @@ func UserSignIn(username, password string) (*User, error) {
} }
sources := make([]*LoginSource, 0, 5) sources := make([]*LoginSource, 0, 5)
if err = x.UseBool().Find(&sources, &LoginSource{IsActived: true}); err != nil { if err = x.Where("is_actived = ?", true).Find(&sources); err != nil {
return nil, err return nil, err
} }

View file

@ -56,7 +56,7 @@ var OAuth2DefaultCustomURLMappings = map[string]*oauth2.CustomURLMapping{
// GetActiveOAuth2ProviderLoginSources returns all actived LoginOAuth2 sources // GetActiveOAuth2ProviderLoginSources returns all actived LoginOAuth2 sources
func GetActiveOAuth2ProviderLoginSources() ([]*LoginSource, error) { func GetActiveOAuth2ProviderLoginSources() ([]*LoginSource, error) {
sources := make([]*LoginSource, 0, 1) 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 nil, err
} }
return sources, nil return sources, nil
@ -64,13 +64,8 @@ func GetActiveOAuth2ProviderLoginSources() ([]*LoginSource, error) {
// GetActiveOAuth2LoginSourceByName returns a OAuth2 LoginSource based on the given name // GetActiveOAuth2LoginSourceByName returns a OAuth2 LoginSource based on the given name
func GetActiveOAuth2LoginSourceByName(name string) (*LoginSource, error) { func GetActiveOAuth2LoginSourceByName(name string) (*LoginSource, error) {
loginSource := &LoginSource{ loginSource := new(LoginSource)
Name: name, has, err := x.Where("name = ? and type = ? and is_actived = ?", name, LoginOAuth2, true).Get(loginSource)
Type: LoginOAuth2,
IsActived: true,
}
has, err := x.UseBool().Get(loginSource)
if !has || err != nil { if !has || err != nil {
return nil, err return nil, err
} }